-
Notifications
You must be signed in to change notification settings - Fork 175
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
Missing empty constructor issue: deserialization breaking change from 2.17 to 2.18 #846
Comments
Needs to be checked against 2.18.1 at least (ideally also 2.18.2-SNAPSHOT, build from 2.18 |
I can confirm the bug with these versions of jackson-module-kotlin:
I also tested with version 2.17.2 and the behavior to assure that the |
The root cause of this also seemed to be the same as #841 (FasterXML/jackson-databind#4777). I first checked how the On the other hand, as a result of |
@baylrock Please include actual exception message (with at least some of the stack trace). |
It looks like intent was for Constructor to use "Delegating" mode; and if so perhaps it is necessary to use annotation
since I don't see any good heuristics for databind to determine this intent (constructor parameter name and underlying property. Not sure why in 2.17 that would be mode selected. EDIT: Actually, I do have a guess. Perhaps it is due to type of single-argument being |
@cowtowncoder issue was found when migrating from 2.12 to 2.18. So it shouldn't be about 2.17 being weird. |
@baylrock That is assuming behavior as of 2.17 was correct, which while not unreasonable assumption is not always true. In case of refactoring of property introspection for 2.18, logic was rewritten to address actual flaws for some well-known cases, but making sure all unit tests pass. Problem here is that there is an unlimited number of combinations, edge cases, and so coverage is always incomplete. While case presented here is not very complex, it seems likely it wasn't covered, and change in logic was not detected. The question, then, is which of behaviors is more correct: that of 2.17, or that of 2.18. Having said that, I do now have one idea wrt why Creater mode heuristics may have changed with 2.18 -- I vaguely remember there being some logic to consider some types (specifically But with all of this said: I would suggest adding explicit
(with whatever mechanism Kotlin requires) |
I take the liberty and step in for baylrock, 'cause I just happened to see the updates to this ticket now. This is the exception when instantiating class
Also, annotating the constructor, as you described, with…
…made the exception go away 🥳 (anyway, my problem turned out to not being the one described here 😊). Thank you cowtowncoder for helping us along! |
Search before asking
Describe the bug
It appears that 2.18 introduced a change to the constructor detection, causing existing use cases to fail. I observed it in a case where a class extending a Map without an empty constructor can no longer be instantiated. See the test case example.
To Reproduce
With jackson 2.18.0 onboard:
Expected behavior
Changes should be backward-compatible per the versioning standard (minor version changed).
Versions
Kotlin:
Jackson-module-kotlin: 2.18.0
Jackson-databind: 2.18.0
Additional context
I'm not 100% sure if this is a Kotlin module issue or not, as I operate in Kotlin codebase only and not invested enough to test it in plane java.
Generally, the fix to the issue is simple; the questionable part is that, if this is intentional, this is technically a breaking change in a minor version change.
The text was updated successfully, but these errors were encountered: