feat: migrate to Jackson 3
Purpose
Migrates the SDK from Jackson 2.17.3 to Jackson 3.0.0, as requested in #370.
⚠️ Jackson 3 requires Java 17. This PR therefore bumps the project baseline from Java 8 to Java 17 (
build.gradle+ CI workflows), which drops Java 8/11 support. That is an inherent consequence of Jackson 3 and a release-level decision — flagging it explicitly.
What changed
build.gradle: switched to thetools.jacksonBOM (jackson-databind3.0.0).jackson-annotationsintentionally stays undercom.fasterxml.jackson(Jackson 3 keeps the annotations package).- Java baseline → 17:
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. - Imports:
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().- Custom (de)serializers:
JsonSerializer/JsonDeserializer→ValueSerializer/ValueDeserializerSerializerProvider→SerializationContextContextualDeserializerremoved —createContextualis now declared onValueDeserializerp.getCodec().readTree(p)→ctxt.readTree(p);getCurrentToken()→currentToken();node.fieldNames()→propertyNames()- dropped
throws IOException(Jackson exceptions are unchecked in 3.x)
- Tests: the deserializer unit tests relied on Jackson 2 internals that were removed 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 StdDateFormat serializes UTC dates as ...Z (canonical ISO-8601) instead of ...+00:00. For example 2019-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's StdDateFormat to restore the +00:00 form; 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.jackson coordinates, and the date-format note above), so it's presumably for the next major release — happy to align on timing/approach.
Closes #370
Heads-up on the build failure — it turned out to be the key point of this migration: Jackson 3 requires Java 17, but the project currently compiles with Java 8 (basic.yml) and build.gradle had sourceCompatibility = 8. So the build couldn't even read Jackson 3's class files (error: cannot access tools.jackson.databind.annotation.JsonDeserialize).
I pushed the necessary follow-up:
- bumped
sourceCompatibilityto 17 and the CI workflows (basic.yml,docs.yml) to Java 17; - removed
import lombok.var;(inHttpException,Sandbox,CrowdinApiTest) — nativevar(Java 10+) replaces it.
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.
Totally fair. The Java 17 floor comes from Jackson 3 itself (the 3.x line requires JDK 17 as its baseline), so there's no way to adopt it without raising the project's baseline — it's inherently a breaking change.
Addressed both review points:
- Removed the leftover
java.io.IOExceptionimports across the json (de)serializers (12 files) and the unusedtools.jackson.core.JacksonExceptionimports (6 files). - Restored the
FileFormatSettingsDeserializerTestassertion toNullPointerException— verified Jackson 3 propagates the NPE from the missingsettingsnode unwrapped, so the specific assertion holds. Full suite still green locally.
Thanks for the update, @GabrielBBaldez - all looks good.
We'd like to hold off on v2.0.0 for now. A major bump is a one-way door, and Jackson 3 / the Java 17 jump alone isn't a strong enough reason yet - Jackson 2.17.x is still fully supported. I'll keep this PR open for the 2.0.0 milestone and fold it in once more breaking changes justify the release. Effort won't go to waste - appreciate it!