Object ID handling tries (unnecessarily) to set id value on a record #4729
Labels
Record
Issue related to JDK17 java.lang.Record support
to-evaluate
Issue that has been received but not yet evaluated
Search before asking
Describe the bug
When using JsonIdentityInfo on a record, Jackson tries to set the id on the record despite it already being correct. This is odd to say the least, as the correct record is already found, which has the correct id (otherwise it wouldn't be found), and then after that it tries to set the id. Here's the code that's causing the problem in
PropertyValueBuffer
:Just before it calls
idProp.setAndReturn
everything is already correct. Thebean
variable holds the correct recordDevice[id=Arris]
. The_idValue
holdsArris
. TheidProp
is[creator property, name 'id'; inject id 'null']
.roId
holds[ObjectId: key=Arris, type=com.fasterxml.jackson.databind.deser.impl.PropertyBasedObjectIdGenerator, scope=java.lang.Object]
.In other words, it found the correct bean, which already has the correct id, but Jackson wants to still set the id value ... to the same value...
Remvoing the line
return idProp.setAndReturn(bean, _idValue);
makes the deserialization work correctly.Version Information
2.18.0
Reproduction
Run below snippet. It will throw an exception:
Expected behavior
I'd expect this to just work out of the box. It shouldn't be trying to call setters on a record under any circumstances...
Additional context
No response
The text was updated successfully, but these errors were encountered: