Skip to content

Commit d7b8e87

Browse files
committed
Some additions to null handling via coercion
1 parent d0447e8 commit d7b8e87

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/main/java/com/fasterxml/jackson/databind/deser/SettableBeanProperty.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,12 @@ public final Object deserialize(JsonParser p, DeserializationContext ctxt) throw
526526
if (_valueTypeDeserializer != null) {
527527
return _valueDeserializer.deserializeWithType(p, ctxt, _valueTypeDeserializer);
528528
}
529-
return _valueDeserializer.deserialize(p, ctxt);
529+
// 04-May-2018, tatu: [databind#2023] Coercion from String (mostly) can give null
530+
Object value = _valueDeserializer.deserialize(p, ctxt);
531+
if (value == null) {
532+
value = _nullProvider.getNullValue(ctxt);
533+
}
534+
return value;
530535
}
531536

532537
/**
@@ -551,7 +556,15 @@ public final Object deserializeWith(JsonParser p, DeserializationContext ctxt,
551556
getName()));
552557
// return _valueDeserializer.deserializeWithType(p, ctxt, _valueTypeDeserializer);
553558
}
554-
return _valueDeserializer.deserialize(p, ctxt, toUpdate);
559+
// 04-May-2018, tatu: [databind#2023] Coercion from String (mostly) can give null
560+
Object value = _valueDeserializer.deserialize(p, ctxt, toUpdate);
561+
if (value == null) {
562+
if (NullsConstantProvider.isSkipper(_nullProvider)) {
563+
return toUpdate;
564+
}
565+
value = _nullProvider.getNullValue(ctxt);
566+
}
567+
return value;
555568
}
556569

557570
/*

0 commit comments

Comments
 (0)