-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Error deserializing generic type hierarchy #814
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
Comments
Could you include serialization from line
since that could give a hint as to what is going on. Exception itself suggests that the serialization of |
The serialization looks like it's working correctly: {"id":1,"children":[{"id":101,"name":null}]} which is what I'd expect (unless I'm missing something). The code looks like it should work to me too. My attempt at using |
It appears Jackson is getting confused by the parent and child classes both having a type parameter GenericParent<S extends GenericChild> |
I'm seeing the same issue. Renaming generic parameterizations so that no two in the same inheritance tree share the same variable name fixed it. I thought I was going mad. |
Yes, unfortunately there are no known issues related to aliasing of type variables (there are couple of unit tests under So I suspect this is due to same root cause as #76. |
Thanks to reimplementation of generic type resolution, this should now work with 2.7(.0-rc1) without having to use specific type variable name. |
I have a generic parent type:
with two generic subclasses:
and two further concrete subclasses:
When I try to deserialize an instance of ConcreteParent, I get the following error:
It appears that Jackson tries to deserialize the "id" field on ConcreteParent into an instance of ConcreteChild. I'm guessing it's something to do with the shared generic superclass and the parameterisation of GenericParent with respect to GenericChild.
I've tried to resolve this using @JsonTypeInfo annotations without success. Is there a combination of annotations that might help? Also worth noting, if I change the id field in GenericIdentifiableObject from T to Integer, the problem goes away. Unfortunately I'm not in a position to make this change to the classes I need to deserialize.
The JUnit test case below illustrates the error. This is using Jackson 2.5.0, dependencies as follows:
The text was updated successfully, but these errors were encountered: