-
-
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
Failed to specialize Map
type during serialization where type key type incompatibility overidden via "raw" types
#1964
Comments
Looks like there is some kind of a problem with type compatibility of declarations. What would be most helpful would be a simplified example, wherein |
I've updated the gist with a working example. |
I didn't want to create new issue, but I'm also having same exception when serializing or deserializing classes with nested generic types. |
@ptirador Then it may be problem with declarations: as I understand it, it is not legal to subtype with different type parameters, except for return type co-variance (of type itself, but not its parameterization?). @antonio-tomac Same exception does not necessarily mean same root cause, but I guess it's fine to be tacked here for now. |
Any update on this? |
@cowtowncoder are there any news/updates regarding this issue? :) |
If there is an update I will add an update. So no. |
As far as I can see, the problem seems to be in TypeFactory#_verifyAndResolvePlaceholders in line 460. There is checked, if the two raw classes are equal. In this example this would be Object and String. In my opinion instanceof or isAssignableFrom should be used instead. |
@julseik I can have a look to see if that makes sense. Type assignability can be bit dangerous, so I want to make sure this is legal. |
@ptirador I am bit confused. With 2.9.5, gist given works. How does the failing case differ from this? |
@cowtowncoder Sorry, I've just updated the gist. Could you try now with that one? I've tried with versions from 2.9.3 to 2.9.5 and it does not work. |
I'm also seeing this problem with 2.9.3, 2.9.4, and 2.9.5. I'll be happy to test any RC with a fix. |
Ok. I don't think original test is valid, and to me it looks like Jackson might be doing the right thing here.
forces key type to be Test works around this by using "raw" type:
since compiler would correctly catch the issue if trying to use
(where type assingments do not work) So. Type system used here is inconsistent. Having said that, this is for serialization side and given that it is possible to force type mismatch, perhaps there is a case to be made that some kinds of coercion should be possible. |
Quick note: realized that use of "static typing" can be used to work around the problem, because that will force use of declared type over attempting to combine declared (static) type with runtime instance type. Although you may or may not want to force it globally (
and this will prevent the problem here. So it may be worth considering this as short-term fix; if this is actual type for real use case it should be safe for serialization. I will still pursue potential change I outlined above, but thought work-around would be useful. |
Map
type during serialization where type key type incompatibility overidden via "raw" types
Jackson versions newer than 2.9.2 and older than 2.9.6 have problems with serializing static types: FasterXML/jackson-databind#1964 Until v2.9.6 become available we have to live with this workaround described here https://github.com/FasterXML/jackson- databind/issues/1964#issuecomment-382877148
Jackson versions newer than 2.9.2 and older than 2.9.6 have problems with serializing static types: FasterXML/jackson-databind#1964 Until v2.9.6 become available we have to live with this workaround described here https://github.com/FasterXML/jackson- databind/issues/1964#issuecomment-382877148
Was this actually fixed? I'm using |
@jhoanmanuelms The reported issue as per gist. If you are experiencing problems, please file a new issue so we can reproduce it and see what is going on. Even if exception looks the same does not necessarily mean the root cause is the same; usually there is some variation. |
I'm using a class with a
Map
attribute, whose value is aCollection
. I'm using OrientDB, so when I obtain this object from database, it's returning a OTrackedMap object.When I'm trying to serialize it, it works perfect until Jackson v2.9.2. If I upgrade it to v2.9.3 or v2.9.4, it crashes with the following exception:
You can take a look at this gist to see an example.
The text was updated successfully, but these errors were encountered: