Skip to content

Commit fb2d03c

Browse files
committed
Fix #1842
1 parent 0ee3f5c commit fb2d03c

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

release-notes/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Project: jackson-databind
1313
(reported byb henryptung@github)
1414
#1807: Jackson-databind caches plain map deserializer and use it even map has `@JsonDeserializer`
1515
(reported by lexas2509@github)
16+
#1842: `null` String for `Exception`s deserialized as String "null" instead of `null`
17+
(reported by ZeleniJure@github)
1618
#1843: Include name of unsettable property in exception from `SetterlessProperty.set()`
1719
(suggested by andreh7@github)
1820

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ public JsonDeserializer<Object> buildThrowableDeserializer(DeserializationContex
437437
builder.addIgnorable("suppressed");
438438
/* As well as "message": it will be passed via constructor,
439439
* as there's no 'setMessage()' method
440-
*/
440+
*/
441441
builder.addIgnorable("message");
442442

443443
// update builder now that all information is in?

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
107107
// Maybe it's "message"?
108108
if (PROP_NAME_MESSAGE.equals(propName)) {
109109
if (hasStringCreator) {
110-
throwable = _valueInstantiator.createFromString(ctxt, p.getText());
110+
throwable = _valueInstantiator.createFromString(ctxt, p.getValueAsString());
111111
// any pending values?
112112
if (pending != null) {
113113
for (int i = 0, len = pendingIx; i < len; i += 2) {

src/test/java/com/fasterxml/jackson/databind/exc/ExceptionDeserializationTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,15 @@ public void testLineNumberAsString() throws IOException
170170
), IOException.class);
171171
assertNotNull(exc);
172172
}
173+
174+
// [databind#1842]:
175+
public void testNullAsMessage() throws IOException
176+
{
177+
Exception exc = MAPPER.readValue(aposToQuotes(
178+
"{'message':null, 'localizedMessage':null }"
179+
), IOException.class);
180+
assertNotNull(exc);
181+
assertNull(exc.getMessage());
182+
assertNull(exc.getLocalizedMessage());
183+
}
173184
}

0 commit comments

Comments
 (0)