jackson-json-crypto
jackson-json-crypto copied to clipboard
Use serializer from `createContextual` as base deserializer
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.
why isn't this included in 2.1?
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:.