diff --git a/src/test/java/com/fasterxml/jackson/failing/NullConversionWithCreatorTest.java b/src/test/java/com/fasterxml/jackson/failing/NullConversionWithCreator2024Test.java similarity index 96% rename from src/test/java/com/fasterxml/jackson/failing/NullConversionWithCreatorTest.java rename to src/test/java/com/fasterxml/jackson/failing/NullConversionWithCreator2024Test.java index 58bb1072bf..4a743eda54 100644 --- a/src/test/java/com/fasterxml/jackson/failing/NullConversionWithCreatorTest.java +++ b/src/test/java/com/fasterxml/jackson/failing/NullConversionWithCreator2024Test.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.exc.InvalidNullException; -public class NullConversionWithCreatorTest extends BaseMapTest +public class NullConversionWithCreator2024Test extends BaseMapTest { // [databind#2024] static class EmptyFromNullViaCreator { @@ -37,6 +37,7 @@ public FailFromNullViaCreator(@JsonSetter(nulls=Nulls.FAIL) /* Test methods /********************************************************** */ + private final ObjectMapper MAPPER = newJsonMapper(); // [databind#2024] diff --git a/src/test/java/com/fasterxml/jackson/failing/NullConversions2458Test.java b/src/test/java/com/fasterxml/jackson/failing/NullConversions2458Test.java new file mode 100644 index 0000000000..d7a095a513 --- /dev/null +++ b/src/test/java/com/fasterxml/jackson/failing/NullConversions2458Test.java @@ -0,0 +1,35 @@ +package com.fasterxml.jackson.failing; + +import java.util.List; +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; + +import com.fasterxml.jackson.databind.*; + +public class NullConversions2458Test extends BaseMapTest +{ + static class Pojo { + private final List list; + + @JsonCreator + public Pojo(@JsonProperty("list") List list) { + this.list = Objects.requireNonNull(list, "list"); + } + + public List getList() { + return list; + } + } + + public void testNullsViaCreator() throws Exception { + ObjectMapper mapper = newJsonMapper(); + mapper.setDefaultSetterInfo(JsonSetter.Value.construct(Nulls.AS_EMPTY, + Nulls.AS_EMPTY)); + Pojo pojo = mapper.readValue("{}", Pojo.class); + assertNotNull(pojo); + } +}