diff --git a/release-notes/VERSION b/release-notes/VERSION index ad90e39464..be5b091d5a 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -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) diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerFactory.java b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerFactory.java index 795e33161a..e4aca12dba 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerFactory.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerFactory.java @@ -437,7 +437,7 @@ public JsonDeserializer 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? diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/std/ThrowableDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/deser/std/ThrowableDeserializer.java index c164c1c501..68ee9faf46 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/std/ThrowableDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/std/ThrowableDeserializer.java @@ -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) { diff --git a/src/test/java/com/fasterxml/jackson/databind/exc/ExceptionDeserializationTest.java b/src/test/java/com/fasterxml/jackson/databind/exc/ExceptionDeserializationTest.java index bf3587d3bd..536a5b4286 100644 --- a/src/test/java/com/fasterxml/jackson/databind/exc/ExceptionDeserializationTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/exc/ExceptionDeserializationTest.java @@ -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()); + } }