-
-
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
Auto-detection of constructor-based creator method skipped if there is an annotated factory-based creator method (regression from 2.11) #2962
Comments
My first reaction is that I have no idea how this could ever have worked, to be honest. "42" and then with
JSON String would need to be matching input for { "version" : 42} (although with coercion could also accept I guess it is possible that formerly this constructor of
but it expects as I guess I could see that possibly working, and maybe even allowing coercion from String to I'll leave this open to hopefully have another look in near future. |
In the given example, we use Jackson 2.11.3
Jackson 2.12.0
Indeed, it uses the private constructor to deserialize |
Ah! Thank you for clarification. That makes more sense. It may still be tricky wrt delegation aspects, but makes more sense regarding how it worked (and possibly should work). |
Yes, adding |
Ok thank you for verifying these aspects. It sounds like there is an unintended change in behavior here, and I hope to look into it when I get a chance. |
I think the problem is that logic is now expecting annotations for (about) everything if there is one annotation.
will actually return auto-detection of the constructor. But it might be possible to re-enable auto-detection of only some of delegating "legacy" creators (for |
So, rewritten code in 2.12 (meant to work same way as before) had checks so that:
but apparently logic earlier was
so that existence of annotated factory method was the difference. Will change code to use older logic, to try to keep backwards-compatibility. This is bit tricky going forward as definition is not very crisp, but seems like the right thing to do for now. |
Number
throws MismatchedInputException
in Jackson 2.12.0
Thanks @cowtowncoder |
Describe the bug
First, I am not sure whether it's a bug or expected behavior, but I just wanted to open an issue for my understanding. Prior to Jackson 2.12.0, it was possible to bind a
Number
(e.g.,42
) to a single field DTO (see example code below). Now, it throwsMismatchedInputException
with this message:Version information
2.12.0
To Reproduce
The code below can be used.
Some notes:
Number
to Dto object.Expected behavior
As I wrote at the beginning, I am not sure whether it's a bug or expected behavior. If it's a bug then, the example code should print
true
instead of throwing an exception.Additional context
N/A
The text was updated successfully, but these errors were encountered: