Deserialized collection fields ignores @Serdeable.Deserializable(as = ...)
#635
Labels
type: improvement
A minor improvement to an existing feature
Milestone
Expected Behavior
When
@Serdeable.Deserializable(as = X.class)
is specified on a deserialized collection/map field, Instance of this type will be used for this field instead of the default oneSame behaviour should be observed with
@JsonDeserialize(as = X.class)
which is mentioned as supported in the documentation (https://micronaut-projects.github.io/micronaut-serialization/latest/guide/#jacksonAnnotations)Jackson deserialization respects
@JsonDeserialize(as = X.class)
and constructs the field with the specified type.Actual Behaviour
Default collection type is constructed for given field (i.e.
ArrayList<X>
forList<X>
property, etc.) instead the specified type.Steps To Reproduce
Example:
The problem is captured in the reproducer in: https://github.com/oujesky/micronaut-serde-as-bug/blob/main/src/test/java/com/example/MicronautSerdeAsBugTest.java including comparison with Jackson (which passes).
Both
testMicronautObjectMapperWithMicronautAnnotations
andtestMicronautObjectMapperWithJacksonAnnotations
fails withExpecting actual to be an instance of: java.util.LinkedList but was instance of: java.util.ArrayList
Environment Information
Example Application
https://github.com/oujesky/micronaut-serde-as-bug/
Version
4.1.6
The text was updated successfully, but these errors were encountered: