-
-
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
Deserialization of class with generic collection inside depends on how is was deserialized first time #676
Comments
At first look, I suspect this may be the case where it is not possible to support polymorphic handling, because all that is known, statically, is that a That is, at least not currently possible to support. Theoretically perhaps it would be possible to include generic type signature instead of raw class; although in this case even that would not be help, when From user perspective, it may be possible to make this case work by using "default typing", in which case determination of whether type information is included is based on checking what kind of class we have. If applied to |
Thank you, @cowtowncoder, for investigating the case. In both cases serialization gives JSON with all necessary information, that is: {"value":
{"@class":"com.fasterxml.jackson.databind.test.JacksonPolymorphicDeSerFailTest$MapContainer",
"map":
{"DateValue":
["java.util.Date",123456]
}
}
} However, if one tries to first call ObjectMapper.readValue(jsonStr, MapContainer.class) he'll get correct map values henceforth, no matter if he deserializes ObjectMapper.readValue(jsonStr, PolymorphicValueWrapper.class)
So Jackson can do its job pretty good. Looks like some internal cache is built differently in each case. To workaround the problem I "initialize" |
That does sound like a bug. A unit test to reproduce this would be great, as behavior simply does not make sense. Your guess as to root cause sounds plausible. |
This is still a big mystery. Disabling caching for both |
Maybe we could think of more test cases with type variations, map size, etc? |
@lunaticare I am not sure whether that would help figure out where the problem occurs, unfortunately. But it does seem like polymorphic handling is required, so provingdisproving that (failing without polymorphic type or not) could help. My best guess is that polymorphic type is indeed required. |
Actually, yes, it was due to caching in cases where it shouldnt, due to type handler existence. |
@cowtowncoder thank you very much! |
Hi everyone!
After migration from Jackson 1.9.x to 2.x (the problem can be reproduced in 2.5.0) I've got a problem deserializing generic collections.
Here's the test that documents the behavour.
Am I doing something wrong?
The text was updated successfully, but these errors were encountered: