Skip to content

Commit a699637

Browse files
committed
tiny change to merging of JsonNodes
1 parent eeda3ff commit a699637

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

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

+14-12
Original file line numberDiff line numberDiff line change
@@ -364,25 +364,27 @@ protected final JsonNode updateObject(JsonParser p, DeserializationContext ctxt,
364364
JsonToken t = p.nextToken();
365365

366366
// First: see if we can merge things:
367-
JsonNode value = node.get(key);
368-
if (value != null) {
369-
if (value instanceof ObjectNode) {
370-
JsonNode newValue = updateObject(p, ctxt, (ObjectNode) value);
371-
if (newValue != null) {
367+
JsonNode old = node.get(key);
368+
if (old != null) {
369+
if (old instanceof ObjectNode) {
370+
JsonNode newValue = updateObject(p, ctxt, (ObjectNode) old);
371+
if (newValue != old) {
372372
node.set(key, newValue);
373-
continue;
374373
}
375-
} else if (value instanceof ArrayNode) {
376-
JsonNode newValue = updateArray(p, ctxt, (ArrayNode) value);
377-
if (newValue != null) {
374+
continue;
375+
}
376+
if (old instanceof ArrayNode) {
377+
JsonNode newValue = updateArray(p, ctxt, (ArrayNode) old);
378+
if (newValue != old) {
378379
node.set(key, newValue);
379-
continue;
380380
}
381+
continue;
381382
}
382383
}
383384
if (t == null) { // can this ever occur?
384-
t = JsonToken.NOT_AVAILABLE; // can this ever occur?
385+
t = JsonToken.NOT_AVAILABLE;
385386
}
387+
JsonNode value;
386388
JsonNodeFactory nodeFactory = ctxt.getNodeFactory();
387389
switch (t.id()) {
388390
case JsonTokenId.ID_START_OBJECT:
@@ -412,11 +414,11 @@ protected final JsonNode updateObject(JsonParser p, DeserializationContext ctxt,
412414
default:
413415
value = deserializeAny(p, ctxt, nodeFactory);
414416
}
415-
JsonNode old = node.replace(key, value);
416417
if (old != null) {
417418
_handleDuplicateField(p, ctxt, nodeFactory,
418419
key, node, old, value);
419420
}
421+
node.set(key, value);
420422
}
421423
return node;
422424
}

0 commit comments

Comments
 (0)