Tested on 2.8.* and 2.9.0.pr4
Given an interface
@JsonSerialize(as = ImmutableTest.class)
@JsonDeserialize(as = ImmutableTest.class)
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class)
public interface ITest {
Integer getId();
String getName();
}
that has two implementations
public static class ImmutableTest implements ITest {
private final Integer id;
private final String name;
...
@JsonCreator(mode = DELEGATING)
static ImmutableTest fromJson(JsonTest json) {
return new ImmutableTest(json.id, json.name);
}
}
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
public static class JsonTest implements ITest {
private String name;
private Integer id;
...
}
and a collection of the interface as input for deserialization
[
{ "@id":1, "id":1, "name":"test" },
1
]
the method annotated with @JsonCreator is not being invoked when deserializing the second collection item (referred by @id:1), resulting in an invalid collection - one item being of type ImmutableTest while the other one is JsonTest.
The setup mimics the way immutables.io library generated classes implement jackson compatibility.
Minimal test case that has classes identical to those generated by immutables.io library: https://gist.github.com/balysv/bae96686cbbb745d07b198927f1577f0
I'm not quite sure if the issue is a misuse of jackson annotations by the generated classes or something internal in jackson-databind. Would appreciate hints of how to get the given setup work.
Tested on
2.8.*and2.9.0.pr4Given an interface
that has two implementations
and a collection of the interface as input for deserialization
the method annotated with
@JsonCreatoris not being invoked when deserializing the second collection item (referred by@id:1), resulting in an invalid collection - one item being of typeImmutableTestwhile the other one isJsonTest.The setup mimics the way immutables.io library generated classes implement jackson compatibility.
Minimal test case that has classes identical to those generated by immutables.io library: https://gist.github.com/balysv/bae96686cbbb745d07b198927f1577f0
I'm not quite sure if the issue is a misuse of jackson annotations by the generated classes or something internal in jackson-databind. Would appreciate hints of how to get the given setup work.