Skip to content

GH-10058: Add Jackson 3 (de)serializer support #10193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

anthologia
Copy link
Contributor

@anthologia anthologia commented Jul 6, 2025

Related to: #10058

  • Add Jackson3-compatible messaging (de)serializers
  • Add Jackson 3 messagingAwareMapper() support
  • Maintain existing Jackson 2 functionality

I thought about splitting this into separate PRs ((de)serializers + messagingAwareMapper() support), but figured it'd be easier to review as one. It's a bit large though - apologies for the extra work! 😅

Now, I have a few questions..

Package Structure

With many Jackson 2 / Jackson 3 classes in the same package, how about reorganizing Jackson 2 into sub-package?

org.springframework.integration.support.json/
├── jackson2/

Copyright and Authors

When refactoring the classes, I moved existing impls and created new ones, following the team's previous decision:

After team discussion, we prefer to have this as a JacksonJsonObjectMapper instead.
And try to keep the rest of API without a number as long as we have that Jackson2 variants.

Originally posted by @artembilan in #10160 (comment)

E.g., :

  • *JacksonDeserializer*Jackson2Deserializer (Jackson 2 support)
  • Updated *JacksonDeserializer for Jackson 3 support

I've attempted to update @author and copyright year appropriately, but please review if they're handled correctly.

Docs

Currently, Many docs (e.g., redis.adoc) references the default class names:

Starting with version 4.3.10, the Framework provides Jackson serializer and deserializer implementations for Message instances and MessageHeaders instances — MessageJacksonDeserializer and MessageHeadersJacksonSerializer, respectively.

With this PR, we now have version-specific implementations:

  • Jackson 2: MessageHeadersJackson2Serializer
  • Jackson 3: MessageHeadersJacksonSerializer

Should we update docs to reflect current impl(Jackson 2) or keep it for 7.0 release since Jackson 3 will be the default?

Related to: spring-projects#10058

* Add Jackson3-compatible messaging (de)serializers
* Add Jackson 3 `messagingAwareMapper()` support
* Maintain existing Jackson 2 functionality

Signed-off-by: Jooyoung Pyoung <[email protected]>
Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*JacksonDeserializer → *Jackson2Deserializer

thank you for the effort !
I’ll take a look tommorow in details, but I think this is a wrong direction.

we develop here a library for target project to rely on the API. We cannot break anything just because. It could be possible in target product where no one depend on your public API. With frameworks and libraries we don’t have such a liberty.
Therefore renaming existing classes, or moving them to different packages is wrong direction for us.
my apologies that my comment about naming was not so clear. Let me try again!
We only deprecate existing classes. We name new classes without a number, as much as possible. No need in a new package since deprecated classes will be removed in next version.
Again: we need to keep in mind that our code is used to compile other projects: breaking an API so dramatically is not acceptable.
Please, revise your solution.

@anthologia
Copy link
Contributor Author

Thank you for taking the time to review this on the weekend !

I apologize for not fully considering that I'm contributing to a widely-used library. At my job, I work on middleware primarily focusing on backward compatibility for end-user functionality, but I hadn't deeply thought about the compatibility of public APIs that other projects depend on. I'll be much more careful to consider API dependencies and backward compatibility in my contributions.

For easier review, I'll revert *Jackson2Deserializer back to *JacksonDeserializer and add *Jackson3Deserializer instead. I'd appreciate any further guidance when you have a chance !

* Keep existing `*JacksonDeserializer` classes unchanged
* Add new `*Jackson3Deserializer` classes for Jackson 3 support

Signed-off-by: Jooyoung Pyoung <[email protected]>
JavaType baseType,
PolymorphicTypeValidator subtypeValidator,
Collection<NamedType> subtypes, boolean forSer, boolean forDeser) {
JavaType baseType,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix it(indentation) when applying the review feedback.

@@ -168,7 +168,7 @@ private static final class AllowListTypeIdResolver implements TypeIdResolver {

private final TypeIdResolver delegate;

private final Set<String> trustedPackages = new LinkedHashSet<>(DEFAULT_TRUSTED_PACKAGES);
private final Set<String> trustedPackages = new LinkedHashSet<>(JacksonJsonUtils.DEFAULT_TRUSTED_PACKAGES);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DITTO

@@ -0,0 +1,48 @@
/*
* Copyright 2017-present the original author or authors.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix these years when applying the review feedback 😂

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.

2 participants