jackson-json-crypto icon indicating copy to clipboard operation
jackson-json-crypto copied to clipboard

Use serializer from `createContextual` as base deserializer

Open mtf90 opened this issue 5 years ago • 2 comments

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 avatar Nov 12 '19 08:11 mtf90

why isn't this included in 2.1?

kecksk0enig avatar Jun 11 '21 15:06 kecksk0enig

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 :laughing:.

mtf90 avatar Jan 25 '22 09:01 mtf90