yasson icon indicating copy to clipboard operation
yasson copied to clipboard

@JsonbTypeDeserializer ignored on parent

Open redmitry opened this issue 3 years ago • 2 comments
trafficstars

Describe the bug The deserializer defined on the parent type is ignored while working OK with JsonbConfig.

To Reproduce

  1. create two classes: Animal and Cat
  2. annotate Animal with @JsonbTypeDeserializer(AnimalDeserializer.class)
  3. try to deserialize Cat (!)

Expected behavior Even though the Cat is deserialized I expect the custom deserializer is called, It works when it is passed to the JsonBuilder: JsonbBuilder.create(new JsonbConfig().withDeserializers(new AnimalDeserializer()))

System information:

  • OS: Windows 10 version 10.0 running on amd64
  • Java Version: OpenJDK 64-Bit Server VM 11.0.15+10-LTS
  • Yasson: 3.0.1

Additional context See simple maven project attached yasson-test-001.zip

redmitry avatar Aug 09 '22 09:08 redmitry

I think, I found the problem: AnnotationIntrospector does not introspect parents for the @JsonbTypeDeserializer annotation. It just returns the 'null':

        if (deserializerAnnotation == null) {
            return null;
        }

I tried simple sulution and it seems to work. issue-569.patch.txt

PS the same should work for the #467

redmitry avatar Aug 09 '22 15:08 redmitry

Hi @redmitry , thank you for reporting this issue and taking time to create the patch :-) I will take a look into what you have found.

Verdent avatar Aug 15 '22 08:08 Verdent