Skip to content

Commit ea91b3a

Browse files
committed
Minor fix to CollectionDeserializer to fix FasterXML/jackson-dataformats-text#199
1 parent 893de72 commit ea91b3a

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

release-notes/VERSION-2.x

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Project: jackson-databind
88

99
#2486: Builder Deserialization with JsonCreator Value vs Array
1010
(reported by Ville K)
11+
- Minor fix to `CollectionDeserializer` to help with [dataformats-text#199] (CSV)
1112

1213
2.11.0 (26-Apr-2020)
1314

src/main/java/com/fasterxml/jackson/databind/deser/std/CollectionDeserializer.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,13 @@ public Collection<Object> deserialize(JsonParser p, DeserializationContext ctxt)
236236
// there is also possibility of "auto-wrapping" of single-element arrays.
237237
// Hence we only accept empty String here.
238238
if (p.hasToken(JsonToken.VALUE_STRING)) {
239-
String str = p.getText();
240-
if (str.length() == 0) {
241-
return (Collection<Object>) _valueInstantiator.createFromString(ctxt, str);
239+
// 16-May-2020, tatu: As [dataformats-text#199] need to avoid blocking
240+
// check to `isExpectedStartArrayToken()` (needed for CSV in-field array/list logic)
241+
if (_valueInstantiator.canCreateFromString()) {
242+
String str = p.getText();
243+
if (str.length() == 0) {
244+
return (Collection<Object>) _valueInstantiator.createFromString(ctxt, str);
245+
}
242246
}
243247
}
244248
return deserialize(p, ctxt, createDefaultInstance(ctxt));

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ private void _testEmptyToNullCoercion(Class<?> primType, Object emptyValue) thro
564564
public void testBase64Variants() throws Exception
565565
{
566566
final byte[] INPUT = "abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890X".getBytes("UTF-8");
567-
567+
568568
// default encoding is "MIME, no linefeeds", so:
569569
Assert.assertArrayEquals(INPUT, MAPPER.readValue(
570570
quote("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwWA=="),
@@ -585,7 +585,7 @@ public void testBase64Variants() throws Exception
585585
Assert.assertArrayEquals(INPUT, (byte[]) reader.with(Base64Variants.PEM).readValue(
586586
quote("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwYWJjZGVmZ2hpamts\\nbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwWA=="
587587
)));
588-
}
588+
}
589589

590590
/*
591591
/**********************************************************

0 commit comments

Comments
 (0)