-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Milestone
Description
(note: copied from FasterXML/jackson-module-kotlin#335)
Looks like following test case, first found with Kotlin, fails:
public class ExternalPropertyTypeShouldBeNullTest {
static class Box {
public String type;
public Fruit fruit;
public Box(@JsonProperty("type") String type,
@JsonTypeInfo(use = Id.NAME, include = As.EXTERNAL_PROPERTY, property = "type")
@JsonSubTypes({@Type(value = Orange.class, name = "orange")})
@JsonProperty("fruit") Fruit fruit) {
this.type = type;
this.fruit = fruit;
}
}
interface Fruit{}
static class Orange implements Fruit {
public String name;
public String color;
public Orange(@JsonProperty("name") String name, @JsonProperty("name") String color) {
this.name = name;
this.color = color;
}
}
private final ObjectMapper MAPPER = new ObjectMapper();
@Test
public void testDeserializationNull() throws Exception {
MAPPER.disable(DeserializationFeature.FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY);
Box deserOrangeBox = MAPPER.readValue("{\"type\":null,\"fruit\":null}}", Box.class);
assertNull(deserOrangeBox.fruit);
assertNull(deserOrangeBox.type); // error: "expected null, but was:<null>"
}
}
Metadata
Metadata
Assignees
Labels
No labels