Skip to content

Commit eea460b

Browse files
committed
Fix #2015 (or, rather, add test to verify, likely fixed with #2023)
1 parent a50ef5a commit eea460b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

release-notes/VERSION-2.x

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ Project: jackson-databind
2121
#2001: Deserialization issue with `@JsonIgnore` and `@JsonCreator` + `@JsonProperty`
2222
for same property name
2323
(reported, fix contributed by Jakub S)
24+
#2015: `@Jsonsetter with Nulls.SKIP` collides with
25+
`DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL` when parsing enum
26+
(reported by ndori@github)
2427
#2016: Delegating JsonCreator disregards JsonDeserialize info
2528
(reported by Carter K)
2629
#2019: Abstract Type mapping in 2.9 fails when multiple modules are registered

src/test/java/com/fasterxml/jackson/databind/deser/filter/NullConversionsSkipTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ public void setValue(String v) {
3636
}
3737
}
3838

39+
// for [databind#2015]
40+
enum NUMS2015 {
41+
ONE, TWO
42+
}
43+
44+
public static class Pojo2015 {
45+
@JsonSetter(value = "number", nulls = Nulls.SKIP)
46+
NUMS2015 number = NUMS2015.TWO;
47+
}
48+
3949
/*
4050
/**********************************************************
4151
/* Test methods, straight annotation
@@ -72,6 +82,15 @@ public void testSkipNullMethod() throws Exception
7282
assertEquals("a", result._nullsOk);
7383
}
7484

85+
// for [databind#2015]
86+
public void testEnumAsNullThenSkip() throws Exception
87+
{
88+
Pojo2015 p = MAPPER.readerFor(Pojo2015.class)
89+
.with(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL)
90+
.readValue("{\"number\":\"THREE\"}");
91+
assertEquals(NUMS2015.TWO, p.number);
92+
}
93+
7594
/*
7695
/**********************************************************
7796
/* Test methods, defaulting

0 commit comments

Comments
 (0)