Skip to content

Conversation

@mtf90
Copy link

@mtf90 mtf90 commented Nov 12, 2019

Jackson seems to provide different DeserializationContext instances to the deserialize and createContextual methods. We have observed that the getContextualType() method on the context passed to the deserialize method would often return null, whereas the context passed to createContextual would correctly allow one to extract the contextual type.

The current implementation does not allow one to use the correct context in their own serializer, since the context passed to the delegating createContextual method is always the one of the serialize method. This pull-requests creates the effective serializer in the createContextual method instead of the deserialize method.

Wether or not the two different contexts may be an actual bug in Jackson, I believe this change still handles the delegation process more cleanly by delegating to the createContextual call in the actual createContextual method.

@mtf90 mtf90 changed the title Use seralizer from createContextual as base deserializer Use serializer from createContextual as base deserializer Nov 12, 2019
@kecksk0enig
Copy link

why isn't this included in 2.1?

@mtf90 mtf90 force-pushed the contextualDeserialization branch from f1c5d89 to 44f4340 Compare January 25, 2022 09:41
@mtf90
Copy link
Author

mtf90 commented Jan 25, 2022

We recently ran into the same issue again when upgrading our Wildfly stack (and switching to jackson-json-crypto 2.2.0).

I noticed that the PR was no longer mergable so I rebased it against the latest master. Are there any objections to merging this? It would certainly make life easier not having to ship a custom hot-fix version for this 😆.

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.

3 participants