Creator properties are ignored on abstract types when collecting bean properties, breaking AsExternalTypeDeserializer #4920
Labels
to-evaluate
Issue that has been received but not yet evaluated
Search before asking
Describe the bug
When using Jackson with frameworks such as Immutables where users are expected to write bean definitions as abstract types and let the framework generate concrete implementations, Jackson annotations on the abstract type sometimes have no effect, or worse, trigger bugs. This appears to be due to the assumption in
BeanDeserializerFactory.addBeanProps
that creator properties do not need to be considered for abstract types. In particular, deserialisation fails with a bizarre exception in in the following situation:ValueInstantiator
(e.g. from a@JsonCreator
annotated factory method).@JsonTypeInfo
annotation withinclude = JsonTypeInfo.As.EXTERNAL_PROPERTY
.Version Information
2.17.1
Reproduction
See attached: example.zip
Expected behavior
No response
Additional context
Deserialisation fails with the following exception:
Notice that the call chain goes through
BeanDeserializer.deserializeFromObjectUsingNonDefault
rather than the expectedBeanDeserializer.deserializeWithExternalTypeId
. This is because_externalTypeIdHandler
isnull
, which is because whenBeanDeserializerBase.resolve
is called,_beanProperties
is empty (!), which is becauseBeanDeserializerFactory.addBeanProps
ignores creator properties when the type is abstract. Changing the value ofisConcrete
inaddBeanProps
totrue
while running in a debugger suffices to fix this problem, though I cannot say if this has any other effects.The text was updated successfully, but these errors were encountered: