-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Failure with custom Enum key deserializer, polymorphic types #1441
Comments
Thank you for reporting this. It sounds like work-around used to allow some value deserializers to be used as key deserializers has some issues. |
Wow. Not sure why I implemented delegating key deserializer that way; it's wrong -- should not delegate original parser in general, and in this case parser would be wrong due to buffering needed for type id. Thank you for reporting this, providing test case! Fixed for 2.8.5, to be released relatively soon (within next week or two). |
Normally the
JsonParser
and theDeserializationContext
is passed to aModule
'sJsonDeserializer
.However, in the
MapDeserializer
, when deserializing aMap
with anEnum
key, theKeyDeserializer
doesn't accept theJsonParser
as an argument:https:/FasterXML/jackson-databind/blob/master/src/main/java/com/fasterxml/jackson/databind/deser/std/MapDeserializer.java#L453
Object key = keyDes.deserializeKey(keyStr, ctxt);
and the
StdKeyDeserializer.DelegatingKD
uses the context's parserhttps:/FasterXML/jackson-databind/blob/master/src/main/java/com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer.java#L315
Object result = _delegate.deserialize(ctxt.getParser(), ctxt);
When the type info field is missing from the json, the
DeserializationContext
'sJsonParser
's token isEND_OBJECT
(presumably because itnextToken
'd through the object to find type and whiffed).This makes the module fail since the
JsonParser
in theModule
is wrong, i.e. not the same as theJsonParser
in theMapDeserializer
.Class:
Enum:
Test:
The text was updated successfully, but these errors were encountered: