-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creator properties are ignored on abstract types when collecting bean properties, breaking AsExternalTypeDeserializer #4920
Comments
Have you tried other versions of jackson-databind, eg v2.18.2? |
The line in question has not been changed for 8 years, but yes, I confirm that it is broken in 2.18.2 too. jackson-databind/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerFactory.java Line 508 in 287af92
|
In case of abstract types, perhaps introspection could try to find factory Creator methods -- constructors should not be used as they cannot really be used directly. |
Isn't that what the |
@zhenlin-pay2 Yes, But in case of What would be useful here would be actual minimized unit test (under |
I am saying that |
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: