Skip to content

Commit f293824

Browse files
authored
Yet moar test coverage (#5491)
1 parent fa318d2 commit f293824

File tree

2 files changed

+8
-48
lines changed

2 files changed

+8
-48
lines changed

src/main/java/tools/jackson/databind/deser/jdk/UntypedObjectDeserializerNR.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -353,48 +353,6 @@ protected Object _deserializeFP(JsonParser p, DeserializationContext ctxt)
353353
}
354354
return p.getDoubleValue();
355355
}
356-
357-
// NOTE: copied from above (alas, no easy way to share/reuse)
358-
// @since 2.12 (wrt [databind#2733]
359-
protected Object _mapObjectWithDups(JsonParser p, DeserializationContext ctxt,
360-
final Map<String, Object> result, String initialKey,
361-
Object oldValue, Object newValue, String nextKey)
362-
throws JacksonException
363-
{
364-
final boolean squashDups = ctxt.isEnabled(StreamReadCapability.DUPLICATE_PROPERTIES);
365-
366-
if (squashDups) {
367-
_squashDups(result, initialKey, oldValue, newValue);
368-
}
369-
370-
while (nextKey != null) {
371-
p.nextToken();
372-
newValue = deserialize(p, ctxt);
373-
oldValue = result.put(nextKey, newValue);
374-
if ((oldValue != null) && squashDups) {
375-
_squashDups(result, nextKey, oldValue, newValue);
376-
}
377-
nextKey = p.nextName();
378-
}
379-
380-
return result;
381-
}
382-
383-
// NOTE: copied from above (alas, no easy way to share/reuse)
384-
@SuppressWarnings("unchecked")
385-
private void _squashDups(final Map<String, Object> result, String key,
386-
Object oldValue, Object newValue)
387-
{
388-
if (oldValue instanceof List<?>) {
389-
((List<Object>) oldValue).add(newValue);
390-
result.put(key, oldValue);
391-
} else {
392-
ArrayList<Object> l = new ArrayList<>();
393-
l.add(oldValue);
394-
l.add(newValue);
395-
result.put(key, l);
396-
}
397-
}
398356

399357
/*
400358
/**********************************************************************

src/test/java/tools/jackson/databind/interop/UntypedObjectWithDupsTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ static class StringStringMap extends LinkedHashMap<String,String> { };
2424
private final String DOC_WITH_DUPS = a2q(
2525
"{'hello': 'world',\n"
2626
+ "'lists' : 1,\n"
27-
+ "'lists' : 2,\n"
27+
+ "'lists' : 2.5,\n"
2828
+ "'lists' : {\n"
2929
+ " 'inner' : 'internal',\n"
3030
+ " 'time' : 123\n"
3131
+ "},\n"
32-
+ "'lists' : 3,\n"
33-
+ "'single' : 'one'\n"
32+
+ "'lists' : true,\n"
33+
+ "'single' : 'one',\n"
34+
+ "'lists' : false,\n"
35+
+ "'lists' : null\n"
3436
+ "}");
3537

3638
// Testing the baseline non-merging behavior
@@ -84,7 +86,7 @@ private <T> void _verifyDupsNoMerging(Class<T> cls) throws Exception
8486

8587
String json = JSON_MAPPER.writeValueAsString(value);
8688
assertEquals(a2q(
87-
"{'hello':'world','lists':3,'single':'one'}"),
89+
"{'hello':'world','lists':null,'single':'one'}"),
8890
json);
8991
}
9092

@@ -94,8 +96,8 @@ private <T> void _verifyDupsNoMerging(Class<T> cls) throws Exception
9496
private void _verifyDupsAreMerged(Class<?> cls) throws Exception
9597
{
9698
assertEquals(a2q(
97-
"{'hello':'world','lists':[1,2,"
98-
+"{'inner':'internal','time':123},3],'single':'one'}"),
99+
"{'hello':'world','lists':[1,2.5,"
100+
+"{'inner':'internal','time':123},true,false,null],'single':'one'}"),
99101
_readWriteDupDoc(DOC_WITH_DUPS, cls));
100102
}
101103

0 commit comments

Comments
 (0)