-
Notifications
You must be signed in to change notification settings - Fork 118
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
[2.10.0] Regression deserializing Optional<JsonNode> #154
Comments
I think I would need a test case that does not use Immutables -- that is, post-processed classes generated. |
The following code also exhibits this difference in behavior. Try running the following with
|
Thank you. |
Ok. I can reproduce the test, but I am actually not sure whether this is a bug or feature. The problem is this: serializing empty Behavior wrt deserialization could be changed by one of 2 things:
but the challenge there is whether this would break some other handling. Doing (1) will break one test in jackson-databind, wrt JDK serializability (although fundamentally just due to NullNode <-> null in json ambiguity). Doing (2) might be safer, although once again it is not certain it would not break something else. |
FWTW, if you want to change behavior to work around the issue, you can sub-class (or just create alternative version) of |
Was trying to remember why the change was made (on May 7th, 2019), and finally found it: FasterXML/jackson-databind#2303 which is... legit, I suppose. But I am not sure there is a way to change behavior to make One possibility I suppose would be adding a configuration setting. |
I think this change is also part of the new behavior : |
Just my 5 cents. I was looking around for a way how to differentiate between a field with Just a short example: Assuming I have a Java DTO with a field of
In that way I could easily differentiate between these two cases and implement the logic accordingly. It might be especially important for implementing PATCH methods in CRUD APIs (no field - no changes; field is But now I see that the logic is different: Optional is set to What do you think, guys? Maybe there is a workaround for my problem? If so, I will appreciate any link or idea. |
@proshin-roman Could you please file a new issue, outlining specific request. With 2.13 (or maybe rather 2.14) I think we actually could resolve/improve this -- 2.13 added a new method
that would be the key here. I was tempted to work on The reason for new issue would be to distinguish question of 2.10 behavior change (which by now is... defined to be intended as 2.11, 2.12 and 2.13 do it) from the question of how things should work. You can refer to this issue from the new one as background. |
Closing this issue in favor of new ones. |
See the following code example.
When using
jackson-databind
2.10.0 andjackson-datatype-jdk8
2.9.10 with immutablesvalue
2.8.1 the code works as expected:deserialized
equalssimpleTest
.When using
jackson-datatype-jdk8
2.10.0, the two values are no longer equal. The deserialized JsonNode isOptional[null]
rather thanOptional.empty
.The text was updated successfully, but these errors were encountered: