Inconsistent behavior on deserialization of immutable classes vs records with @JsonIdentityInfo #3307
Labels
try-with-later-jackson
Indicator that the issue needs to be verified against later version
Describe the bug
When using @JsonIdentityInfo, Jackson deserializes an immutable class fine but the equivalent record does not.
Version information
Jackson 2.13.0
To Reproduce
I have a simple immutable class defined as follows:
The equivalent record is as follows:
The XML being deserialized is the following:
Finally, I have the following mapper (building with -parameters):
When I deserialize the XML to the first class it works fine, but when I do so to the second class I get the following error:
Can not set final java.lang.String field com.opengg.loader.Project$ProjectResource.name to java.lang.String
Maybe I'm doing something wrong, but my understanding of the record constructor syntax is that it generates the constructor in the same format as the immutable class, including any annotations. If the two classes are identical, I don't see a reason why the deserializer would be unable to use the constructor in the record case but have it work fine in the class case.
EDIT:
This seems to be related to #3297.
The text was updated successfully, but these errors were encountered: