Skip to content

Stop CoreJacksonModule from overriding user DateTimeFeature configuration#19043

Open
hqqw2h-lgtm wants to merge 1 commit intospring-projects:mainfrom
hqqw2h-lgtm:gh-18561
Open

Stop CoreJacksonModule from overriding user DateTimeFeature configuration#19043
hqqw2h-lgtm wants to merge 1 commit intospring-projects:mainfrom
hqqw2h-lgtm:gh-18561

Conversation

@hqqw2h-lgtm
Copy link
Copy Markdown

@hqqw2h-lgtm hqqw2h-lgtm commented Apr 5, 2026

Summary

Fixes #18561

CoreJacksonModule.setupModule() unconditionally called enable(DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS) on the MapperBuilder, which overrode any user configuration and forced all java.time types (e.g. LocalDateTime, Instant) to be serialized as timestamps/arrays instead of ISO-8601 strings.

Changes

  • Removed the global enable(DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS) call from CoreJacksonModule.setupModule()
  • Added @jsonformat(shape = JsonFormat.Shape.NUMBER) annotations on individual Mixin constructor parameters and getters that require timestamp serialization for backward compatibility:
    • FactorGrantedAuthorityMixin.issuedAt (constructor param + getter)
    • OAuth2AccessTokenMixin.issuedAt and expiresAt
    • OAuth2RefreshTokenMixin.issuedAt
    • OidcIdTokenMixin.issuedAt and expiresAt
  • Added 3 new tests in FactorGrantedAuthorityMixinTests:
    • Verifies serialization still produces timestamps even when WRITE_DATES_AS_TIMESTAMPS is globally disabled
    • Verifies deserialization from timestamp format works with the feature disabled
    • Verifies the global DateTimeFeature setting is not overridden by Security modules

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 5, 2026
…tion

Remove the global DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS override
from CoreJacksonModule.setupModule() and use @jsonformat(shape = NUMBER)
on Mixin parameters/getters that need timestamp format for backward
compatibility.

Closes spring-projectsgh-18561

Signed-off-by: hanweiwei <duzielww@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CoreJacksonModule forces WRITE_DATES_AS_TIMESTAMPS=true, overriding user configuration

3 participants