Skip to content

Commit 8238ab4

Browse files
committed
Fix #3473 (re-implementation of #2816 for 2.14)
1 parent f0af53d commit 8238ab4

File tree

6 files changed

+666
-71
lines changed

6 files changed

+666
-71
lines changed

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

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
196196
if ((_stringDeserializer == null) && (_numberDeserializer == null)
197197
&& (_mapDeserializer == null) && (_listDeserializer == null)
198198
&& getClass() == UntypedObjectDeserializer.class) {
199-
return Vanilla.instance(preventMerge);
199+
return UntypedObjectDeserializerNR.instance(preventMerge);
200200
}
201201

202202
if (preventMerge != _nonMerging) {
@@ -659,6 +659,7 @@ protected Object mapObject(JsonParser p, DeserializationContext ctxt,
659659
* is only used when no custom deserializer overrides are applied.
660660
*/
661661
@JacksonStdImpl
662+
@Deprecated // since 2.14, to be removed in near future
662663
public static class Vanilla
663664
extends StdDeserializer<Object>
664665
{
@@ -869,18 +870,10 @@ protected Object mapArray(JsonParser p, DeserializationContext ctxt) throws IOEx
869870
l.add(value);
870871
return l;
871872
}
872-
Object value2 = deserialize(p, ctxt);
873-
if (p.nextToken() == JsonToken.END_ARRAY) {
874-
ArrayList<Object> l = new ArrayList<Object>(2);
875-
l.add(value);
876-
l.add(value2);
877-
return l;
878-
}
879873
ObjectBuffer buffer = ctxt.leaseObjectBuffer();
880874
Object[] values = buffer.resetAndStart();
881875
int ptr = 0;
882876
values[ptr++] = value;
883-
values[ptr++] = value2;
884877
int totalSize = ptr;
885878
do {
886879
value = deserialize(p, ctxt);
@@ -898,9 +891,6 @@ protected Object mapArray(JsonParser p, DeserializationContext ctxt) throws IOEx
898891
return result;
899892
}
900893

901-
/**
902-
* Method called to map a JSON Array into a Java Object array (Object[]).
903-
*/
904894
protected Object[] mapArrayToArray(JsonParser p, DeserializationContext ctxt) throws IOException {
905895
ObjectBuffer buffer = ctxt.leaseObjectBuffer();
906896
Object[] values = buffer.resetAndStart();
@@ -918,9 +908,6 @@ protected Object[] mapArrayToArray(JsonParser p, DeserializationContext ctxt) th
918908
return result;
919909
}
920910

921-
/**
922-
* Method called to map a JSON Object into a Java value.
923-
*/
924911
protected Object mapObject(JsonParser p, DeserializationContext ctxt) throws IOException
925912
{
926913
// will point to FIELD_NAME at this point, guaranteed
@@ -929,33 +916,15 @@ protected Object mapObject(JsonParser p, DeserializationContext ctxt) throws IOE
929916
p.nextToken();
930917
Object value1 = deserialize(p, ctxt);
931918

932-
String key2 = p.nextFieldName();
933-
if (key2 == null) { // single entry; but we want modifiable
934-
LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(2);
935-
result.put(key1, value1);
936-
return result;
937-
}
938-
p.nextToken();
939-
Object value2 = deserialize(p, ctxt);
940-
941919
String key = p.nextFieldName();
942-
if (key == null) {
943-
LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(4);
920+
if (key == null) { // single entry; but we want modifiable
921+
LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(2);
944922
result.put(key1, value1);
945-
if (result.put(key2, value2) != null) {
946-
// 22-May-2020, tatu: [databind#2733] may need extra handling
947-
return _mapObjectWithDups(p, ctxt, result, key1, value1, value2, key);
948-
}
949923
return result;
950924
}
951925
// And then the general case; default map size is 16
952926
LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>();
953927
result.put(key1, value1);
954-
if (result.put(key2, value2) != null) {
955-
// 22-May-2020, tatu: [databind#2733] may need extra handling
956-
return _mapObjectWithDups(p, ctxt, result, key1, value1, value2, key);
957-
}
958-
959928
do {
960929
p.nextToken();
961930
final Object newValue = deserialize(p, ctxt);

0 commit comments

Comments
 (0)