diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 77f9c318be..1587651535 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,7 @@ Project: jackson-databind #2486: Builder Deserialization with JsonCreator Value vs Array (reported by Ville K) +- Minor fix to `CollectionDeserializer` to help with [dataformats-text#199] (CSV) 2.11.0 (26-Apr-2020) diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/std/CollectionDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/deser/std/CollectionDeserializer.java index e9ed3572cf..e9804cc538 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/std/CollectionDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/std/CollectionDeserializer.java @@ -236,9 +236,13 @@ public Collection deserialize(JsonParser p, DeserializationContext ctxt) // there is also possibility of "auto-wrapping" of single-element arrays. // Hence we only accept empty String here. if (p.hasToken(JsonToken.VALUE_STRING)) { - String str = p.getText(); - if (str.length() == 0) { - return (Collection) _valueInstantiator.createFromString(ctxt, str); + // 16-May-2020, tatu: As [dataformats-text#199] need to avoid blocking + // check to `isExpectedStartArrayToken()` (needed for CSV in-field array/list logic) + if (_valueInstantiator.canCreateFromString()) { + String str = p.getText(); + if (str.length() == 0) { + return (Collection) _valueInstantiator.createFromString(ctxt, str); + } } } return deserialize(p, ctxt, createDefaultInstance(ctxt)); diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/jdk/JDKScalarsTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/jdk/JDKScalarsTest.java index 692f441f69..115163cd11 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/jdk/JDKScalarsTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/jdk/JDKScalarsTest.java @@ -564,7 +564,7 @@ private void _testEmptyToNullCoercion(Class primType, Object emptyValue) thro public void testBase64Variants() throws Exception { final byte[] INPUT = "abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890X".getBytes("UTF-8"); - + // default encoding is "MIME, no linefeeds", so: Assert.assertArrayEquals(INPUT, MAPPER.readValue( quote("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwWA=="), @@ -585,7 +585,7 @@ public void testBase64Variants() throws Exception Assert.assertArrayEquals(INPUT, (byte[]) reader.with(Base64Variants.PEM).readValue( quote("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwYWJjZGVmZ2hpamts\\nbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwWA==" ))); - } + } /* /**********************************************************