feat: migrate to Jackson 3#385
Open
GabrielBBaldez wants to merge 3 commits into
Open
Conversation
Migrates the SDK from Jackson 2.17.3 to Jackson 3.0.0. Closes crowdin#370. - build.gradle: use the tools.jackson BOM (jackson-databind 3.0.0); jackson-annotations stays on com.fasterxml.jackson per Jackson 3 - imports moved from com.fasterxml.jackson.{core,databind} to tools.jackson.* (annotations package unchanged) - JacksonJsonTransformer: ObjectMapper is immutable in 3.x, rebuilt via JsonMapper.builder() (configure, changeDefaultPropertyInclusion(NON_NULL), defaultDateFormat, addModule, changeDefaultVisibility); derived mappers via rebuild() - custom (de)serializers ported: JsonSerializer/JsonDeserializer -> ValueSerializer/ValueDeserializer, SerializerProvider -> SerializationContext, ContextualDeserializer removed (createContextual now declared on ValueDeserializer), p.getCodec().readTree(p) -> ctxt.readTree(p), getCurrentToken() -> currentToken(), node.fieldNames() -> propertyNames(), exceptions are unchecked (dropped throws IOException) - tests: rewrote the deserializer unit tests that relied on removed Jackson 2 internals (JsonParser.setCodec, ObjectMapper.getFactory/getDeserializationContext) to drive deserialization through a configured mapper BREAKING CHANGE: now requires Jackson 3 (tools.jackson coordinates). Jackson 3's StdDateFormat serializes UTC dates as "...Z" (canonical ISO-8601) instead of "...+00:00"; the affected request fixture was updated accordingly. All 579 tests pass.
- Jackson 3 requires Java 17, so bump sourceCompatibility to 17 and the CI workflows (basic.yml, docs.yml) to Java 17. This drops Java 8/11 support, which is an inherent consequence of Jackson 3. - remove 'import lombok.var;' (HttpException, Sandbox, CrowdinApiTest); native var (Java 10+) replaces it.
Contributor
Author
|
Heads-up on the I pushed the necessary follow-up:
So migrating to Jackson 3 inherently requires Java 17 and drops Java 8/11 support. That's a release-level decision rather than something this PR can avoid — flagging it explicitly so you can decide whether it fits the intended target release. All 579 tests pass locally on JDK 17. |
JaCoCo 0.8.5 cannot read Java 17 class files (major version 61), failing jacocoTestReport. Bump to 0.8.11, which supports Java 17/21.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Migrates the SDK from Jackson 2.17.3 to Jackson 3.0.0, as requested in #370.
What changed
build.gradle: switched to thetools.jacksonBOM (jackson-databind3.0.0).jackson-annotationsintentionally stays undercom.fasterxml.jackson(Jackson 3 keeps the annotations package).sourceCompatibilitybumped 8 → 17 and the CI workflows (basic.yml,docs.yml) bumped to Java 17 (Jackson 3's minimum). Removedimport lombok.var;(3 files) in favor of nativevar.com.fasterxml.jackson.{core,databind}.*→tools.jackson.*(annotations untouched;JsonFactorymoved totools.jackson.core.json).JacksonJsonTransformer:ObjectMapperis immutable in 3.x, so the mapper is built withJsonMapper.builder()(configure,changeDefaultPropertyInclusion(NON_NULL),defaultDateFormat,addModule,changeDefaultVisibility); derived mappers userebuild()instead ofcopy().JsonSerializer/JsonDeserializer→ValueSerializer/ValueDeserializerSerializerProvider→SerializationContextContextualDeserializerremoved —createContextualis now declared onValueDeserializerp.getCodec().readTree(p)→ctxt.readTree(p);getCurrentToken()→currentToken();node.fieldNames()→propertyNames()throws IOException(Jackson exceptions are unchecked in 3.x)JsonParser.setCodec,ObjectMapper.getFactory,ObjectMapper.getDeserializationContext). They were rewritten to drive deserialization through a configured mapper (readValue), preserving the same assertions.Heads-up (behavioral change)
Jackson 3's
StdDateFormatserializes UTC dates as...Z(canonical ISO-8601) instead of...+00:00. For example2019-09-23T11:26:54.000+00:00→2019-09-23T11:26:54.000Z. The affected request fixture was updated. There is no built-in option in Jackson 3'sStdDateFormatto restore the+00:00form; both are valid ISO-8601.Testing
All 579 tests pass locally (
./gradlew test, JDK 17).This is a breaking change (requires Java 17, new
tools.jacksoncoordinates, and the date-format note above), so it's presumably for the next major release — happy to align on timing/approach.Closes #370