Skip to content
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

Avoid using generated Jackson serializers for subclasses #46211

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

mariofusco
Copy link
Contributor

Fixes #46156

The reason why it requires 2 different endpoints to reproduce the problem is the following: in the reproducer one endpoint returned objects of class A and the second of class B extending A. The serializer for A is correctly generated and registered. Conversely the serializer for B cannot be generated because the class contains an unknown annotation (JsonIgnore in this case, but this pull request also adds support for it), so Jackson should use the default, reflection based, serializer. However, as discussed here since there's a registered serializer for A and B is also an instance of A, Jackson decides to use the serializer generated for A, thus leaving out the properties of B during serialization. Without the endpoint returning instances of A, no serializers is generated for that class, so the problem doesn't happen. Note that this problem also doesn't happen for deserializers because (for some reason) in that case Jackson use a generated deserializer only if there is one registered exactly for it.

Copy link

quarkus-bot bot commented Feb 11, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 3a4b8b1.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.

@gsmet gsmet merged commit 7050060 into quarkusio:main Feb 11, 2025
36 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.19 - main milestone Feb 11, 2025
@gsmet gsmet modified the milestones: 3.19 - main, 3.18.3 Feb 11, 2025
@mariofusco mariofusco deleted the q46156 branch February 12, 2025 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reflection-free Serialization issue when first accessed vs. second access or if multiple methods
2 participants