Skip to content

Share the library-independent JSON converter code across the Jackson and kotlinx modules - #739

Merged
zantvoort merged 3 commits into
mainfrom
refactor/jackson-version-adapter
Oct 22, 2026
Merged

zantvoort merged 3 commits into
mainfrom
refactor/jackson-version-adapter

Conversation

@zantvoort

Copy link
Copy Markdown
Collaborator

Fixes #409

What is shared now

The library-independent half of the three JSON modules moved into storm-core, in the impl package the modules already import from:

  • JsonConverterSupport, the ORMConverter base: the column, writing to and reading from the database, the ref factory of the conversion in progress with its nesting rule, the mapper cache key, the sealed-type walk. A module binds a library by implementing write and read.
  • RefJsonSupport: the JSON forms of a ref, the primary key type cache, and the creation of loaded, unloaded and compound-key refs.

Jackson 2, Jackson 3 and kotlinx.serialization all build on these. The kotlinx module keeps its flag-keyed mapper cache and its Kotlin serializer resolution; the Jackson modules keep their serializer, deserializer and mapper builder.

What could not be shared

The issue estimated a twelve-line adapter. Jackson calls into the serializer and deserializer with its own types, which Jackson 3 moved to a new package and renamed (ValueSerializer, SerializationContext, DatabindException, JacksonException for IOException, writeName, the removed ContextualSerializer interface, the builder-only mapper). That code stays per module, with the Jackson 3 file as the source and the Jackson 2 file derived from it by the package rename plus those renames. Per module the production code went from 594 to 408 non-blank lines, with 377 shared lines in core; the net change of the PR is minus 911 lines.

Bug found by unifying the tests

On Jackson 3, @Json(failOnUnknown = true) was silently ignored: Jackson 3 turns the unknown-property check off by default and the converter only ever turned it off. Both converters now set failOnUnknown and failOnMissing explicitly, and the suite has rejection tests for both. In the changelog.

Tests

The two Jackson suites had forked to 59 and 83 StormModuleTest methods with different names; they are one suite of 35 tests covering every assertion of both, identical across the modules modulo the package rename, import order and the API-forced lines in custom serializers. JsonORMConverterImplTest is folded into the integration test, JsonMetamodelTest and the Kotlin interop suite now run on Jackson 3 as well (the Jackson 3 Kotlin module is a test dependency), and JsonIntegrationTest writes dates as ISO strings on both. Both Jackson modules pass 90 tests; the kotlinx module passes its 194 unchanged.

…and kotlinx modules

The Jackson 2, Jackson 3 and kotlinx.serialization modules each carried
their own copy of the converter base, the ref factory thread-local, the
key type cache and the ref creation. That code now lives in storm-core,
and each module keeps only what its library's API forces. The two Jackson
test suites, which had forked, are one suite again, which exposed that
Jackson 3 ignored @JSON(failOnUnknown = true): both converters now set
the two features explicitly.

Fixes #409
@zantvoort zantvoort added this to the 1.16.0 milestone Oct 22, 2026
@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Unit tests drive JsonConverterSupport and RefJsonSupport without a JSON
library; the Jackson suite gains the null wrapper payload, the keyless
plain object, a deserializer-only field and unconstructible serializers.
The sealed-type walk now looks inside a plain array, the integral id
fallback returns an Integer when it fits, and a null wrapper payload
reads as no ref on Jackson 2 as it does on Jackson 3.
@zantvoort
zantvoort merged commit 0d1420a into main Oct 22, 2026
8 checks passed
@zantvoort
zantvoort deleted the refactor/jackson-version-adapter branch October 22, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate the Jackson 2 and Jackson 3 modules behind a version adapter

1 participant