yasson
yasson copied to clipboard
@JsonbTypeDeserializer ignored on parent
Describe the bug The deserializer defined on the parent type is ignored while working OK with JsonbConfig.
To Reproduce
- create two classes: Animal and Cat
- annotate Animal with
@JsonbTypeDeserializer(AnimalDeserializer.class) - 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
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
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.