Uh oh!
There was an error while loading. Please reload this page.
Fix #475: Incompatible date serialization default with Jackson 3 - #476
Conversation
There was a problem hiding this comment.
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
DefaultRestClientJacksonJsonMapperbuilder (to avoid ISO-8601 strings by default). - Add a regression test that verifies
java.util.Dateis 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. |
Uh oh!
There was an error while loading. Please reload this page.
| * capturing the raw request body echoed back by the server. | ||
| */ | ||
| @Test | ||
| void testPostDateSerializesAsNumericTimestamp() throws RestClientException { |
There was a problem hiding this comment.
May we please backport this test to 2.1.x just to be sure about this complicated issue?
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…te-compat' into issues/475-date-serialization-date-compat
There was a problem hiding this comment.
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
timestampis 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);
Uh oh!
There was an error while loading. Please reload this page.
No description provided.