diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index d4f3fbc411..e1efce4a97 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -963,3 +963,8 @@ David Connelly (dconnelly@github) Wahey (KevynBct@github) * Reported #2466: Didn't find class "java.nio.file.Path" below Android api 26 (2.10.0) + +Martín Coll (colltoaction@github) + * Contributed #2467: Accept `JsonTypeInfo.As.WRAPPER_ARRAY` with no second argument to + deserialize as "null value" + (2.10.0) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index be873e4235..0b2d907691 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,9 @@ Project: jackson-databind #2466: Didn't find class "java.nio.file.Path" below Android api 26 (reported by KevynBct@github) +#2467: Accept `JsonTypeInfo.As.WRAPPER_ARRAY` with no second argument to + deserialize as "null value" + (contributed by Martin C) 2.10.0.pr3 (17-Sep-2019) diff --git a/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/AsArrayTypeDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/AsArrayTypeDeserializer.java index 6d736c7fd3..2923726203 100644 --- a/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/AsArrayTypeDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/AsArrayTypeDeserializer.java @@ -113,6 +113,7 @@ protected Object _deserialize(JsonParser p, DeserializationContext ctxt) throws p = JsonParserSequence.createFlattened(false, tb.asParser(p), p); p.nextToken(); } + // [databind#2467] (2.10): Allow missing value to be taken as "just use null value" if (hadStartArray && p.currentToken() == JsonToken.END_ARRAY) { return deser.getNullValue(ctxt); } diff --git a/src/test/java/com/fasterxml/jackson/databind/jsontype/TestTypedDeserialization.java b/src/test/java/com/fasterxml/jackson/databind/jsontype/TestTypedDeserialization.java index 59ea371ac3..68e77e2e9b 100644 --- a/src/test/java/com/fasterxml/jackson/databind/jsontype/TestTypedDeserialization.java +++ b/src/test/java/com/fasterxml/jackson/databind/jsontype/TestTypedDeserialization.java @@ -57,7 +57,7 @@ public Cat(@JsonProperty("furColor") String c) { public void setName(String n) { name = n; } } - // for [JACKSON-319] -- allow "empty" beans + // Allow "empty" beans @JsonTypeName("fishy") static class Fish extends Animal { @@ -68,6 +68,7 @@ public Fish() } } + // [databind#2467]: Allow missing "content" for as-array deserialization @JsonDeserialize(using = NullAnimalDeserializer.class) static class NullAnimal extends Animal { @@ -264,6 +265,7 @@ public void testIssue506WithNumber() throws Exception assertEquals(input.number, output.number); } + // [databind#2467]: Allow missing "content" for as-array deserialization public void testTypeAsArrayWithNullableType() throws Exception { ObjectMapper m = new ObjectMapper(); @@ -273,6 +275,7 @@ public void testTypeAsArrayWithNullableType() throws Exception assertNull(a); } + // [databind#2467] public void testTypeAsArrayWithCustomDeserializer() throws Exception { ObjectMapper m = new ObjectMapper();