@@ -364,25 +364,27 @@ protected final JsonNode updateObject(JsonParser p, DeserializationContext ctxt,
364
364
JsonToken t = p .nextToken ();
365
365
366
366
// 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 ) {
372
372
node .set (key , newValue );
373
- continue ;
374
373
}
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 ) {
378
379
node .set (key , newValue );
379
- continue ;
380
380
}
381
+ continue ;
381
382
}
382
383
}
383
384
if (t == null ) { // can this ever occur?
384
- t = JsonToken .NOT_AVAILABLE ; // can this ever occur?
385
+ t = JsonToken .NOT_AVAILABLE ;
385
386
}
387
+ JsonNode value ;
386
388
JsonNodeFactory nodeFactory = ctxt .getNodeFactory ();
387
389
switch (t .id ()) {
388
390
case JsonTokenId .ID_START_OBJECT :
@@ -412,11 +414,11 @@ protected final JsonNode updateObject(JsonParser p, DeserializationContext ctxt,
412
414
default :
413
415
value = deserializeAny (p , ctxt , nodeFactory );
414
416
}
415
- JsonNode old = node .replace (key , value );
416
417
if (old != null ) {
417
418
_handleDuplicateField (p , ctxt , nodeFactory ,
418
419
key , node , old , value );
419
420
}
421
+ node .set (key , value );
420
422
}
421
423
return node ;
422
424
}
0 commit comments