eclipse-ee4j / yasson

Eclipse Yasson project
https://projects.eclipse.org/projects/ee4j.yasson
Other
204 stars 96 forks source link

@JsonbTypeDeserializer ignored on parent #569

Open redmitry opened 2 years ago

redmitry commented 2 years ago

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:

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

redmitry commented 2 years ago

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

Verdent commented 2 years ago

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.