Skip to content

Fix #475: Incompatible date serialization default with Jackson 3 - #476

Merged
romanstrobl merged 5 commits into
developfrom
issues/475-date-serialization-date-compat
Aug 6, 2026
Merged

Fix #475: Incompatible date serialization default with Jackson 3#476
romanstrobl merged 5 commits into
developfrom
issues/475-date-serialization-date-compat

Conversation

@romanstrobl

Copy link
Copy Markdown
Member

No description provided.

@romanstrobl
romanstrobl requested review from banterCZ and a lite review from Copilot August 5, 2026 12:08
@romanstrobl romanstrobl self-assigned this Aug 5, 2026
@romanstrobl romanstrobl added the bug label Aug 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request addresses issue #475 by restoring the historical behavior of DefaultRestClient JSON serialization for date/time values after Jackson 3 changed the default for WRITE_DATES_AS_TIMESTAMPS.

Changes:

  • Force-enable timestamp-based date serialization in the DefaultRestClient Jackson JsonMapper builder (to avoid ISO-8601 strings by default).
  • Add a regression test that verifies java.util.Date is serialized as numeric epoch milliseconds in POST bodies.
  • Add a test-only controller endpoint that echoes the raw JSON request body to make the serialization assertion reliable.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
rest-client-base/src/main/java/com/wultra/core/rest/client/base/DefaultRestClient.java Enables DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS when creating the client JsonMapper to preserve pre-Jackson-3 wire format.
rest-client-base/src/test/java/com/wultra/core/rest/client/base/DefaultRestClientTest.java Adds a regression test validating numeric timestamp serialization for Date by inspecting the echoed raw request JSON.
rest-client-base/src/test/java/com/wultra/core/rest/client/base/controller/PublicTestRestController.java Adds an endpoint to echo the raw JSON request body used by the new regression test.

* capturing the raw request body echoed back by the server.
*/
@Test
void testPostDateSerializesAsNumericTimestamp() throws RestClientException {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May we please backport this test to 2.1.x just to be sure about this complicated issue?

romanstrobl and others added 2 commits August 5, 2026 14:42
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…te-compat' into issues/475-date-serialization-date-compat
@romanstrobl
romanstrobl requested review from banterCZ and a lite review from Copilot August 5, 2026 21:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (1)

rest-client-base/src/test/java/com/wultra/core/rest/client/base/DefaultRestClientTest.java:310

  • The assertions rely on substring matching in the echoed JSON (e.g., exact spacing and a hard-coded ISO-8601 prefix). This can make the regression test brittle if the JSON generator changes formatting (whitespace, ordering) while still serializing the date correctly. Consider parsing the echoed body as JSON and asserting that timestamp is a numeric node with the expected epoch value.
        assertTrue(rawBody.contains("\"timestamp\":1785926829449"),
                "Date must be serialized as numeric epoch milliseconds, was: " + rawBody);
        assertFalse(rawBody.contains("2026-08-"),
                "Date must not be serialized as an ISO-8601 string, was: " + rawBody);

@romanstrobl
romanstrobl merged commit 507e92d into develop Aug 6, 2026
3 checks passed
@romanstrobl
romanstrobl deleted the issues/475-date-serialization-date-compat branch August 6, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants