Fix [JACKSON-794]
diff --git a/release-notes/VERSION b/release-notes/VERSION index 85a58ef..5472888 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION
@@ -8,6 +8,9 @@ Fixes: + * [JACKSON-794]: JDK 7 has new property for Exceptions ("suppressable"), + needs to be ignored during deserialization + ------------------------------------------------------------------------ === History: === ------------------------------------------------------------------------
diff --git a/src/mapper/java/org/codehaus/jackson/map/deser/BeanDeserializerFactory.java b/src/mapper/java/org/codehaus/jackson/map/deser/BeanDeserializerFactory.java index 0b0be35..620c9dc 100644 --- a/src/mapper/java/org/codehaus/jackson/map/deser/BeanDeserializerFactory.java +++ b/src/mapper/java/org/codehaus/jackson/map/deser/BeanDeserializerFactory.java
@@ -761,6 +761,8 @@ * as there's no 'setMessage()' method */ builder.addIgnorable("message"); + // [JACKSON-794]: JDK 7 also added "getSuppressed", skip if we have such data: + builder.addIgnorable("suppressed"); // [JACKSON-440]: update builder now that all information is in? if (_factoryConfig.hasDeserializerModifiers()) {
diff --git a/src/test/org/codehaus/jackson/map/deser/TestExceptionDeserialization.java b/src/test/org/codehaus/jackson/map/deser/TestExceptionDeserialization.java index bc142a1..18bb87f 100644 --- a/src/test/org/codehaus/jackson/map/deser/TestExceptionDeserialization.java +++ b/src/test/org/codehaus/jackson/map/deser/TestExceptionDeserialization.java
@@ -55,12 +55,13 @@ /********************************************************** */ + final ObjectMapper MAPPER = new ObjectMapper(); + public void testIOException() throws IOException { - ObjectMapper mapper = new ObjectMapper(); IOException ioe = new IOException("TEST"); - String json = mapper.writeValueAsString(ioe); - IOException result = mapper.readValue(json, IOException.class); + String json = MAPPER.writeValueAsString(ioe); + IOException result = MAPPER.readValue(json, IOException.class); assertEquals(ioe.getMessage(), result.getMessage()); } @@ -68,10 +69,9 @@ public void testWithCreator() throws IOException { final String MSG = "the message"; - ObjectMapper mapper = new ObjectMapper(); - String json = mapper.writeValueAsString(new MyException(MSG, 3)); + String json = MAPPER.writeValueAsString(new MyException(MSG, 3)); - MyException result = mapper.readValue(json, MyException.class); + MyException result = MAPPER.readValue(json, MyException.class); assertEquals(MSG, result.getMessage()); assertEquals(3, result.value); assertEquals(1, result.stuff.size()); @@ -81,8 +81,8 @@ // [JACKSON-388] public void testWithNullMessage() throws IOException { - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); + final ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); String json = mapper.writeValueAsString(new IOException((String) null)); IOException result = mapper.readValue(json, IOException.class); assertNotNull(result); @@ -91,8 +91,15 @@ public void testNoArgsException() throws IOException { - ObjectMapper mapper = new ObjectMapper(); - MyNoArgException exc = mapper.readValue("{}", MyNoArgException.class); + MyNoArgException exc = MAPPER.readValue("{}", MyNoArgException.class); + assertNotNull(exc); + } + + // [JACKSON-794]: try simulating JDK 7 behavior + public void testJDK7SuppressionProperty() throws IOException + { + Exception exc = MAPPER.readValue("{\"suppressed\":[]}", IOException.class); assertNotNull(exc); } } +