BeanDeserializer does not reset jsonParser currentValue after deserialising nested Object/Collection Node #1834
Labels
need-test-case
To work on issue, a reproduction (ideally unit test) needed
BeanDeserializer assigns the current value before walking the objects fields.
If the objects fields value is a nested object / collection the deserialiser invoked for these values follows the same pattern invoking setCurrentValue. Similairy any custom serialiser for a field may invoke setCurrentValue.
As the currentValue is not reset after deserialisng the nested object or collection. The parsers current value remains the value of traversed nested object or collection.
This is a issue for any custom serializer which might invoke the getCurrentValue as the value is now out of sync with the currentContext and is pointing to some object outside its tree.
This pattern is used throughout BeanDeserializer and CollectionDeserializer and from the comments introduced via ticket: #631
This is present in the current release 2.9.2
Example scenario vanillaDeserialize sets the current value as the object walking(ObjA), the field to serialise is an empty ArrayList the deserialiser invoked for example is CollectionDeserializer which follows this patten and sets the current value in the parser as the ArrayList.
CollectionDeserializer returns setting the value of the field in ObjA to the deserialised ArrayList but the parsers current value remains as the ArrayList.
Fix would be in all deserialisers following this pattern to save a reference to the previousValue and before exiting reset the currentValue
The text was updated successfully, but these errors were encountered: