-
Notifications
You must be signed in to change notification settings - Fork 96
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
Record with no-arg constructor with does not deserialise correctly #549
Comments
Updates as I originally thought it was due to |
Hi Dan, this is happening due to default empty constructor you are having in all of the records. Yasson is trying to find Now I am thinking whether we should throw an exception in cases when record do have multiple constructors (including the default one) and none of them is marked as |
From RecordTest.java:L69 it does suggest that it should throw an exception but I'm not seeing that behaviour in 3.0.0-RC1. 🤔 |
I've just checked and it's due to default no-args constructor behaviour of records. I'd argue a no-arg constructor is a pointless record so should throw an exception regardless. |
Exactly my thought when I was analyzing it yesterday. I will make the needed change :-) |
It does fail for multiple constructors, but since it is taking nearly the same processing path as regular class, I forgot to make it to fail when default constructor is present. It backs to use that and does not fail in this case. :-) |
Describe the bug
If a record has a no-arg constructor when deserialised the optional is always
<empty>
.To Reproduce
An example is available here.
Expected behavior
The correct constructor for the record is selected.
System information:
Additional context
N/A
The text was updated successfully, but these errors were encountered: