diff --git a/src/main/java/com/fasterxml/jackson/databind/JsonMappingException.java b/src/main/java/com/fasterxml/jackson/databind/JsonMappingException.java index 8a4ebb3da4..cc6fb5a21d 100644 --- a/src/main/java/com/fasterxml/jackson/databind/JsonMappingException.java +++ b/src/main/java/com/fasterxml/jackson/databind/JsonMappingException.java @@ -454,6 +454,7 @@ public void prependPath(Reference r) /********************************************************** */ + @JsonIgnore @Override // since 2.7.5 public Object getProcessor() { return _processor; } diff --git a/src/test/java/com/fasterxml/jackson/databind/TestJsonMappingException.java b/src/test/java/com/fasterxml/jackson/databind/TestJsonMappingException.java new file mode 100644 index 0000000000..b0d6b0f346 --- /dev/null +++ b/src/test/java/com/fasterxml/jackson/databind/TestJsonMappingException.java @@ -0,0 +1,32 @@ +package com.fasterxml.jackson.databind; + +import java.io.IOException; + +import org.junit.Test; + +public class TestJsonMappingException { + public static class NoSerdeConstructor { + private String strVal; + public String getVal() { return strVal; } + public NoSerdeConstructor( String strVal ) { + this.strVal = strVal; + } + } + // we know we can't serialize this dumb class above + @Test( expected = JsonMappingException.class ) + public void testNoSerdeConstructor() throws IOException { + ObjectMapper mpr = new ObjectMapper(); + mpr.readValue( "{ \"val\": \"foo\" }", NoSerdeConstructor.class ); + } + // we should, however, be able to serialize the exception arising from the above test + @Test + public void testJsonMappingExceptionIsJacksonSerializable() throws IOException { + ObjectMapper mpr = new ObjectMapper(); + try { + testNoSerdeConstructor(); + } catch ( JsonMappingException exc ) { + // without @JsonIgnore on getProcessor() this causes an error + mpr.writeValueAsString( exc ); + } + } +}