-
-
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
Deserialize null, when java type is "TypeRef of TypeRef of T", does not provide "Type(Type(null))" #2303
Comments
Thank you for reporting this, providing excellent analysis of likely cause. I think you are right on both accounts. I'll this on my WIP page (https://github.com/FasterXML/jackson-future-ideas/wiki/Jackson-Work-in-Progress), but it may take a while until I get to look into it. |
Looking into this. Also, targeting 2.10 since I think there's non-zero risk of downside with any fix, just because test coverage for the case is (obviously) not there. |
I can reproduce the issue as reported, can see the NPE. Now trying to track down the path where there is the discrepancy wrt value deserializer not getting passed... not yet seeing it. |
Hmmh. Ok, I can finally see where the deviation comes from: value deserializer and null value provider are not kept in sync, as both should remain same if they were set the same originally. |
Found a fix and I think it's safe enough to go in 2.9(.9) after all. |
Ok so will be in 2.9.9. A related question is handling of |
Hi cowtowncoder, Sorry for the late answer. I would use getNullValue(). What you did if I correctly read your commit. For information, I worked around the issue by implementing my custom deserializer getNullValue as follow (Kotlin syntax):
@cowtowncoder I think we can provide a default implementation of getNullValue in ReferenceTypeDeserializer. Here my proposal:
I would be able to simplify my code later. Thank you for the fix. |
Ugh. So this caused: FasterXML/jackson-modules-java8#154 for non-nested case... which is not optimal either. |
Dependency
Short explanation
In Kotlin, I got an issue when I deserialize the value in the context of a reference type that include another reference type. I provide here a reproduction scenario in Java based on AtomicReference (I don't think there is a real use-case that use an AR of AR of Integer, but with a kind of DSL, it may happen to have a similar inclusion...)
So, when we deserialize an 22, we get an AR of AR of 22 as expected. But when we deserialize the null value, we get an AR of null (instead of AR of AR of null).
I think there is 2 issues:
(1) the getNull method of AtomicReference always returns "new AtomicReference()". I think it should be smarter and use contextual information such fullType or simply call _valueDeserializer.getNull() -- but _valueDeserializer was null during my tests because of (2).
(2) the bean propertyCreator has distinct deserializer and nullProvider. In the case of ReferenceTypeDeserializer, a new contextual deserializer is created, which is able to deserialize its content. Then the deserializer of the bean propertyCreator is updated, but not its nullProvider
To reproduce
The text was updated successfully, but these errors were encountered: