jackson-databind icon indicating copy to clipboard operation
jackson-databind copied to clipboard

AsDeductionTypeDeserializer assigning values to incorrect objects when used in conjunction with AsPropertyTypeDeserializer

Open perelengo opened this issue 7 months ago • 1 comments

Hi, I was implementing a diffrent algorithm for AsPropertyTypeDeserializer and an issue with the following line raised: https://github.com/FasterXML/jackson-databind/blob/171fb418c4afe50f7aad6235cd5f2c53282a52b2/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/AsPropertyTypeDeserializer.java#L162

The issue seems to be related with the fact that JsonParserSequence is returning an already processed property. In my case, modifying this line with p = tb.asParser(p); fixes the issue.

Sample data:

"ClasswithSubTypes":{
    "AnotherClassWithSubTypes": {
        "text": "aaa"
    },
    "value": "bbb"
}

When ClasswithSubTypes is processed, although value has already been set for the new instance of ClasswithSubTypes, it is trying to assign the ClasswithSubTypes.value property to AnotherClassWithSubTypes due to this JsonParserSequence usage.

perelengo avatar May 16 '25 17:05 perelengo

Unfortunately textual description isn't quite enough, we would need a reproduction (unit test).

But quick question: title refers to both AsDeductionTypeDeserializer and AsPropertyTypeDeserializer -- but nothing in description refers to former. Is title incorrect, or are you somehow trying to combine 2 type deserializers?

cowtowncoder avatar May 16 '25 21:05 cowtowncoder