[Java] fix Jackson 3 createDefaultMapper(null) losing the default date format (restclient, webclient)
Fixes #24588
With useJackson3=true, the Jackson 3 branch of createDefaultMapper passes a null DateFormat straight into JsonMapper.builder().defaultDateFormat(dateFormat). The Jackson 2 branch of the same template falls back to createDefaultDateFormat() when the argument is null. The generator's own entry points (buildRestClientBuilder(), buildRestClient()) call createDefaultMapper(null), so nothing clears WRITE_DATES_AS_TIMESTAMPS and date-time fields serialize as epoch numbers instead of RFC 3339.
Verified against Jackson 3.1.5 with an exact copy of the generated method:
createDefaultMapper(null), master : {"clientId":"client-1","issuedAt":1785605400.000000000}
createDefaultMapper(null), fixed : {"clientId":"client-1","issuedAt":"2026-08-01T17:30:00Z"}
The fix adds the same null fallback the Jackson 2 branch already has. The webclient template has the identical bug (same createDefaultMapper(null) call sites, same missing fallback), so it gets the same 3 lines.
Not touched: #24587 (missing message converters) is a separate bug in the same file and will get its own PR.
Changes:
Java/libraries/restclient/ApiClient.mustache,Java/libraries/webclient/ApiClient.mustache: null fallback in the Jackson 3createDefaultMapper- Regression test
JavaClientCodegenTest#testJackson3DefaultMapperFallsBackToDefaultDateFormat_issue_24588(both libraries) - Regenerated the 4 affected sample configs (java-restclient/webclient-springBoot4-jackson3, plus jspecify variants), 3 lines each, no other drift
Tested: JavaClientCodegenTest 273/273 green.
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
Commit all changed files../mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit - If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Java technical committee: @bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @martin-mfg @KannaKim
Summary by cubic
Fixes incorrect date-time serialization when useJackson3=true by making createDefaultMapper(null) fall back to the default date format in Java restclient and webclient. Date-times now serialize as RFC 3339 strings instead of epoch numbers. Fixes #24588.
- Bug Fixes
- In the Jackson 3 branch of
createDefaultMapper, usecreateDefaultDateFormat()whendateFormatis null (parity with Jackson 2). - Added regression test:
JavaClientCodegenTest#testJackson3DefaultMapperFallsBackToDefaultDateFormat_issue_24588. - Regenerated affected samples (restclient/webclient Spring Boot 4 + Jackson 3, including jspecify).
- In the Jackson 3 branch of