-
-
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
Possible wrong use of _arrayDelegateDeserializer in BeanDeserializerBase::deserializeFromObjectUsingNonDefault #4602
Comments
I checked the The HTH |
Quick note: would be good to verify with latest release (2.17.1). But more importantly, 2.18.0-SNAPSHOT has fully rewritten Bean Property Introspection, which includes Creator detection. |
Other than that, what would be useful is an actual unit test: all the pieces seem to be included. But reproduction would be most useful. Reproduction would ideally be for using JSON (not yaml), without parameter-names module (just use annotations). If it turns out things work in JSON, then would move issue to yaml module repo etc. |
@cowtowncoder thanks for your input I checked it with 2.17.1 and 2.18.0-SNAPSHOT, no dice. The |
I added the test, you can find it in the linked PR #4605 |
Thank you @Gems! |
Ok, so, just because current JSON value is Object does not automatically rule out use of delegating deserializer -- Delegation to, say, But I wonder if |
Turns out, "single value as Array of 1 element" case was indeed caught by one existing unit tests. But I was able to hack a PR to fix this behavior, #4609, which while not as clean as I'd hope, would do the trick. |
Thank you @Gems for reporting the issue and contributing the test! As per my note above, fix will go in 2.18.0 which will take a bit to release (development cycle not yet complete). |
Thank you @cowtowncoder for the prompt response and for fixing it. I look forward to updating my dependency to 2.18.0. |
Search before asking
Describe the bug
Deserialisation doesn't work as expected in case of several Json Creators are defined on a class ( PROPERTIES and DELEGATED), and the delegating one is accepting a
List
as an argument and represents the single mandatory property of the class.It's expected that the PROPERTIES deserializer will be used, but the deserialisation process opts for the delegating deserialiser despite JSON definition being provided as Object.
Version Information
2.16.1
Reproduction
I have the following class definition for a JSON object:
Classes
StepDefinition
andExtraProperties
are simple class with straight-forward mapping.I annotated the
MyDefinition
class in such a way, so it could handle mapping for the following two cases of JSON:Case 1:
Case 2:
The deserialisation for the "PROPERTIES" case (Case 1) fails on trying to deserialise "extra" property value as
StepDefinition
type.Expected behavior
I'd expect that the PROPERTIES deserialiser is used in case the object is provided with a bunch of properties.
Additional context
A similar mapping scenario works in case the delegating factory method accepts
String
as a value (not a list).My mapper is created using
YAMLFactory
and the failure occurs on parsing YAML.The mapper has
DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY
feature enabled, and is configured withParameterNamesModule
I guess it could be important to mention that I also use Lombok.
The text was updated successfully, but these errors were encountered: