Skip to content

Commit 4d97132

Browse files
committed
Merge branch '2.11' into 2.12
2 parents 2644cba + b65606d commit 4d97132

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/test/java/com/fasterxml/jackson/databind/deser/jdk/EnumDefaultReadTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,19 @@ public void testWithFailOnNumbersAndReadUnknownAsDefault()
207207
_verifyOkDeserialization(r, "2", CustomEnumWithDefault.class, CustomEnumWithDefault.ZERO);
208208
}
209209

210+
// [databind#3171]: Ensure "" gets returned as Default Value, not coerced
211+
public void testEmptyStringAsDefault() throws Exception
212+
{
213+
ObjectReader r = MAPPER.readerFor(SimpleEnumWithDefault.class)
214+
.with(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE);
215+
assertEquals(SimpleEnumWithDefault.ONE,
216+
r.readValue(quote("ONE")));
217+
assertEquals(SimpleEnumWithDefault.ZERO,
218+
r.readValue(quote("Zero")));
219+
assertEquals(SimpleEnumWithDefault.ZERO,
220+
r.readValue(quote("")));
221+
}
222+
210223
private <T> void _verifyOkDeserialization(ObjectReader reader, String fromValue,
211224
Class<T> toValueType, T expValue)
212225
throws IOException

0 commit comments

Comments
 (0)