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 5 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 <pyoungjy@gmail.com>
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 <pyoungjy@gmail.com>
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.

Thank you for the effort!
Please, keep in mind that Jackson 2 will be deprecated.

I even wonder if we should do that right now, so then it will become more clear what to implement and where to migrate in tests. I don't say to do that in your current PR, but just an idea for the next step (if any).

Thank you!

* Remove `Jackson3` suffix from deserializer/serializer classes * Copy `DEFAULT_TRUSTED_PACKAGES` from `JacksonJsonUtils` for future deprecation * Inline dedicated method and constants in test Signed-off-by: Jooyoung Pyoung <pyoungjy@gmail.com>
@anthologia
Copy link
Contributor Author

anthologia commented Jul 9, 2025

Thank you for the guidance!

It seems like we're getting closer to the point where Jackson 2 deprecation makes sense. I think we maybe need to add JsonPropertyAccessor support first.

As you mentioned previously, we'll likely be blocked by Jackson 3 migration in other projects. I'm not entirely certain, but from what I've checked, it appears to be Spring Kafka's DefaultKafkaHeaderMapper.

I see you're also a Spring Kafka maintainer. If needed, I'd be happy to help with migration in other projects too. Feel free to ping me on the relevant issues if my contribution would be helpful ! 😁

@artembilan
Copy link
Member

Sure thing, @anthologia !

Here is Spring Kafka part: spring-projects/spring-kafka#3930
And if you are interested this is Spring AMQP part: spring-projects/spring-amqp#3117

@anthologia
Copy link
Contributor Author

I'm not entirely familiar with these projects, but I'd be happy to give both a shot based on what I've learned here!

What's the expected release timeline for AMQP?

@artembilan
Copy link
Member

What's the expected release timeline for AMQP?

For AMQP that was a PR from me to review.
If you want.
Nothing to do over there.
We have milestone in a couple weeks.
But all the plans for Jackson 3 migration are due on this November.
So, we have a plenty of time to clean up as maximum as we could.

Thank you for your help with all of this!

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.

Very good!
Just final nit-pick review.
Thank you!

* Configure checkstyle `NoWhitespaceBefore` tokens to allow varargs spacing * Add `@Nullable` for JSpecify nullability * Fix ClassLoader reference in `JacksonMessagingUtils` Signed-off-by: Jooyoung Pyoung <pyoungjy@gmail.com>
Signed-off-by: Jooyoung Pyoung <pyoungjy@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants