Skip to content

Commit

Permalink
Minor fix to CollectionDeserializer to fix FasterXML/jackson-datafo…
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 16, 2020
1 parent 893de72 commit ea91b3a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,13 @@ public Collection<Object> 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<Object>) _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<Object>) _valueInstantiator.createFromString(ctxt, str);
}
}
}
return deserialize(p, ctxt, createDefaultInstance(ctxt));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=="),
Expand All @@ -585,7 +585,7 @@ public void testBase64Variants() throws Exception
Assert.assertArrayEquals(INPUT, (byte[]) reader.with(Base64Variants.PEM).readValue(
quote("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwYWJjZGVmZ2hpamts\\nbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwWA=="
)));
}
}

/*
/**********************************************************
Expand Down

0 comments on commit ea91b3a

Please sign in to comment.