Skip to content

Commit 4d1f4cf

Browse files
committed
Merge branch '2.11' into 2.12
2 parents 1d80cb6 + 4f4f69d commit 4d1f4cf

3 files changed

Lines changed: 23 additions & 16 deletions

File tree

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public CollectionDeserializer createContextual(DeserializationContext ctxt,
189189
valueTypeDeser = valueTypeDeser.forProperty(property);
190190
}
191191
NullValueProvider nuller = findContentNullProvider(ctxt, property, valueDeser);
192-
if ( (unwrapSingle != _unwrapSingle)
192+
if ((unwrapSingle != _unwrapSingle)
193193
|| (nuller != _nullProvider)
194194
|| (delegateDeser != _delegateDeserializer)
195195
|| (valueDeser != _valueDeserializer)
@@ -236,9 +236,15 @@ 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+
// ... alas, trying to do this here leads to 2 unit test regressions so will
242+
// need to figure out safer mechanism.
243+
// if (_valueInstantiator.canCreateFromString()) {
244+
String str = p.getText();
245+
if (str.length() == 0) {
246+
return (Collection<Object>) _valueInstantiator.createFromString(ctxt, str);
247+
// }
242248
}
243249
}
244250
return deserialize(p, ctxt, createDefaultInstance(ctxt));

src/test/java/com/fasterxml/jackson/databind/deser/TestArrayDeserialization.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
1212
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
1313
import com.fasterxml.jackson.databind.module.SimpleModule;
14+
import com.fasterxml.jackson.databind.util.ClassUtil;
1415

1516
/**
1617
* This unit test suite tries to verify that the "Native" java type
@@ -188,24 +189,24 @@ public void testIntegerArray() throws Exception
188189
// [JACKSON-620]: allow "" to mean 'null' for Arrays, List and Maps
189190
public void testFromEmptyString() throws Exception
190191
{
191-
ObjectMapper m = new ObjectMapper();
192-
m.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
193-
assertNull(m.readValue(quote(""), Object[].class));
194-
assertNull( m.readValue(quote(""), String[].class));
195-
assertNull( m.readValue(quote(""), int[].class));
192+
ObjectReader r = MAPPER.reader()
193+
.with(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
194+
assertNull(r.forType(Object[].class).readValue(quote("")));
195+
assertNull(r.forType(String[].class).readValue(quote("")));
196+
assertNull(r.forType(int[].class).readValue(quote("")));
196197
}
197198

198199
// [JACKSON-620]: allow "" to mean 'null' for Arrays, List and Maps
199200
public void testFromEmptyString2() throws Exception
200201
{
201-
ObjectMapper m = new ObjectMapper();
202-
m.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
203-
m.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
204-
Product p = m.readValue("{\"thelist\":\"\"}", Product.class);
202+
ObjectReader r = MAPPER.readerFor(Product.class)
203+
.with(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT,
204+
DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
205+
Product p = r.readValue("{\"thelist\":\"\"}");
205206
assertNotNull(p);
206207
assertNull(p.thelist);
207208
}
208-
209+
209210
/*
210211
/**********************************************************
211212
/* Arrays of arrays...

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

Lines changed: 2 additions & 2 deletions
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)