-
-
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
Wrong constructor picked up when deserializing object #1476
Comments
@laurentgo Thank you for reporting this. I think explicit Should be fixed for 2.8.6; but may take a while since I will be on vacation starting tomorrow (until january). |
Sounds good. Would it be backported to 2.7.x branch, or is this branch definitively closed? |
@laurentgo 2.7 is not yet closed so unless fix is particularly intrusive will probably backport for 2.7.9 as well. |
Interesting. So, I can reproduce with code exactly as is. But almost any change (like commenting out just one of 1-arg constructors; or replacing getters with public fields) will make test pass... |
Thanks for fixing this. Yes, I agree that the test case is very fragile but that I was the best I could come up with at that time :) |
I discovered an issue with Jackson 2.7.8 (and Jackson 2.8.4) when several constructors have parameters annotated with
@JsonProperty
but only one is annotated with@JsonCreator
.Here's a test case to reproduce it:
This test throws an the following exception:
After some debugging, it looks like that
BasicDeserializerFactory#_addDeserializerConstructors(...)
is looping over all the constructors, and is not favoring an explicit constructor over a non-explicit one.I actually don't know what should be the expected behavior: should jackson fail when two constructors are annotated, or should jackson favor the one annotated with
@JsonCreator
. Both options look reasonable to me (and I'm actually removing one of the constructors).The text was updated successfully, but these errors were encountered: