Skip to content

Commit ccd7212

Browse files
committed
Merge branch '2.7'
2 parents bb06aa0 + 1904839 commit ccd7212

File tree

5 files changed

+41
-2
lines changed

5 files changed

+41
-2
lines changed

release-notes/CREDITS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,11 @@ Max Drobotov (fizmax@github)
476476
* Reported, contributed fix for #1332: `ArrayIndexOutOfBoundException` for enum by index deser
477477
(2.7.7)
478478

479+
Josh Caplan (jecaplan@github)
480+
* Reported, suggested fix for #1368: Problem serializing `JsonMappingException` due to addition
481+
of non-ignored `processor` property (added in 2.7)
482+
(2.7.8)
483+
479484
Artur Jonkisz (ajonkisz@github)
480485
* Reported #960: `@JsonCreator` not working on a factory with no arguments for ae enum type
481486
(2.8.0)

release-notes/VERSION

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ Project: jackson-databind
9393
#1359: Improve `JsonNode` deserializer to create `FloatNode` if parser supports
9494
#1362: ObjectReader.readValues()` ignores offset and length when reading an array
9595
(reported by wastevenson@github)
96+
#1368: Problem serializing `JsonMappingException` due to addition of non-ignored
97+
`processor` property (added in 2.7)
98+
(reported, suggesed fix by Josh C)
9699

97100
2.7.7 (27-Aug-2016)
98101

src/main/java/com/fasterxml/jackson/databind/JsonMappingException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ public List<Reference> getPath()
401401
}
402402

403403
/**
404-
* Method for accesing description of path that lead to the
404+
* Method for accessing description of path that lead to the
405405
* problem that triggered this exception
406406
*/
407407
public String getPathReference()
@@ -455,6 +455,7 @@ public void prependPath(Reference r)
455455
*/
456456

457457
@Override // since 2.7.5
458+
@JsonIgnore // as per [databind#1368]
458459
public Object getProcessor() { return _processor; }
459460

460461
@Override

src/test/java/com/fasterxml/jackson/databind/deser/TestExceptionDeserialization.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static class MyNoArgException extends Exception
4444
{
4545
@JsonCreator MyNoArgException() { }
4646
}
47-
47+
4848
/*
4949
/**********************************************************
5050
/* Tests

src/test/java/com/fasterxml/jackson/databind/ser/TestExceptionSerialization.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ public ExceptionWithIgnoral(String msg) {
2626
}
2727
}
2828

29+
// [databind#1368]
30+
static class NoSerdeConstructor {
31+
private String strVal;
32+
public String getVal() { return strVal; }
33+
public NoSerdeConstructor( String strVal ) {
34+
this.strVal = strVal;
35+
}
36+
}
37+
2938
/*
3039
/**********************************************************
3140
/* Tests
@@ -91,4 +100,25 @@ public void testIgnorals() throws Exception
91100
assertNotNull(output);
92101
assertEquals("foobar", output.getMessage());
93102
}
103+
104+
// [databind#1368]
105+
public void testJsonMappingExceptionSerialization() throws IOException {
106+
Exception e = null;
107+
// cant deserialize due to unexpected constructor
108+
try {
109+
MAPPER.readValue( "{ \"val\": \"foo\" }", NoSerdeConstructor.class );
110+
fail("Should not pass");
111+
} catch (JsonMappingException e0) {
112+
verifyException(e0, "no suitable constructor");
113+
e = e0;
114+
}
115+
// but should be able to serialize new exception we got
116+
String json = MAPPER.writeValueAsString(e);
117+
JsonNode root = MAPPER.readTree(json);
118+
String msg = root.path("message").asText();
119+
String MATCH = "no suitable constructor";
120+
if (!msg.contains(MATCH)) {
121+
fail("Exception should contain '"+MATCH+"', does not: '"+msg+"'");
122+
}
123+
}
94124
}

0 commit comments

Comments
 (0)