Skip to content

Commit

Permalink
Fix #1842
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 30, 2017
1 parent 0ee3f5c commit fb2d03c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project: jackson-databind
(reported byb henryptung@github)
#1807: Jackson-databind caches plain map deserializer and use it even map has `@JsonDeserializer`
(reported by lexas2509@github)
#1842: `null` String for `Exception`s deserialized as String "null" instead of `null`
(reported by ZeleniJure@github)
#1843: Include name of unsettable property in exception from `SetterlessProperty.set()`
(suggested by andreh7@github)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public JsonDeserializer<Object> buildThrowableDeserializer(DeserializationContex
builder.addIgnorable("suppressed");
/* As well as "message": it will be passed via constructor,
* as there's no 'setMessage()' method
*/
*/
builder.addIgnorable("message");

// update builder now that all information is in?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
// Maybe it's "message"?
if (PROP_NAME_MESSAGE.equals(propName)) {
if (hasStringCreator) {
throwable = _valueInstantiator.createFromString(ctxt, p.getText());
throwable = _valueInstantiator.createFromString(ctxt, p.getValueAsString());
// any pending values?
if (pending != null) {
for (int i = 0, len = pendingIx; i < len; i += 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,15 @@ public void testLineNumberAsString() throws IOException
), IOException.class);
assertNotNull(exc);
}

// [databind#1842]:
public void testNullAsMessage() throws IOException
{
Exception exc = MAPPER.readValue(aposToQuotes(
"{'message':null, 'localizedMessage':null }"
), IOException.class);
assertNotNull(exc);
assertNull(exc.getMessage());
assertNull(exc.getLocalizedMessage());
}
}

0 comments on commit fb2d03c

Please sign in to comment.