Repository navigation
Conversation
Restore @DynamoDBTypeConvertedJson and its tests exactly as they were at f8d9c8c, before #7502 removed them, so the next commit shows only the changes needed to drop the jackson-databind dependency. This commit does not compile on its own: the annotation still imports jackson-databind, which the mapper no longer depends on.
Call jackson-databind through reflection instead of depending on it, so the mapper ships without databind and @DynamoDBTypeConvertedJson uses the application's copy. The calls and configuration match the v1 converter exactly, so stored JSON stays the same. When databind is missing, the mapper throws a DynamoDBMappingException naming the dependency to add, when it builds the model for an annotated class. Add tests against v1's own converter, a test run with databind removed from the classpath, and databind as a test-only dependency.
Check @DynamoDBTypeConvertedJson against JSON recorded from v1's converter (aws-java-sdk-dynamodb 1.12.797 on jackson-databind 2.17.2) over 145 cases. Writes must match byte for byte. Classes with getter-only properties are compared without regard to property order, because jackson-databind orders those by getDeclaredMethods(), which differs between JVMs even in v1.
RanVaknin
force-pushed
the
rvaknin/add-DynamoDBTypeConvertedJson-back
branch
from
November 20, 2026 22:25
f9cd5c6 to
e7322fe
Compare
DynamoDBTypeConvertedJson annotation back, without relying on jackson-databind
This branch has not been deployed
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.
Motivation and Context
PR #7502 removed S3link which transitively brought in jackson-databind. As a result
DynamoDBTypeConvertedJsonbroke since it relies on databind for reflection, applying ruleset and writing / read to and from JSON.The team has decided to not rely on databind directly because of large number of CVEs it has associated with it, and instead reflectively find the objectmapper class that should be on a customer's classpath when they have this annotation. This avoids any direct or optional dependencies on databind, but it would mean a runtime failure for customers who use this annotation but do not bring this dependency themselves.
Modifications
This PR has 2 commits:
7412384- is just a verbatim copy and bring back of the removed annotation and tests.f9cd5c6- this is where the changes are for this PR and so this is the Commit that provides the actual diff.e7322feadds the v1 fixture compliance tests.Since we don't want to depend on jackson-databind, we can get around it by reflectively examining the class loader for databind's ObjectMapper class. and calls it through reflection. This allows customers who do not use this annotation to not have a dependency on databind, and customers who do use this annotation to provide their own databind or fail at runtime.
For reference, Apache Groovy does the same thing.
Alternative considered:
I have considered just making jackson-databind optional, but that would still list it in the mapper's published pom, where scanners would flag its CVEs on the mapper artifact.
Testing
We still must depend on databind as a test dependency.
Aside from the tests that were pre-existing before #7502
Types of changes
Checklist
AI tools
License