Skip to content

Commit 52c52a5

Browse files
committed
Merge branch '2.8'
2 parents fdd9596 + ab4f17f commit 52c52a5

10 files changed

+84
-30
lines changed

release-notes/CREDITS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,10 @@ Pavel Popov (tolkonepiu@github)
554554
* Contributed fix #1389: Problem with handling of multi-argument creator with Enums
555555
(2.8.4)
556556

557+
Josh Gruenberg (joshng@github)
558+
* Reported #1403: Reference-chain hints use incorrect class-name for inner classes
559+
(2.8.4)
560+
557561
Connor Kuhn (ckuhn@github)
558562
* Contributed #1341: FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY
559563
(2.9.0)

release-notes/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Project: jackson-databind
3737
(reported by Rob W)
3838
#1395: Problems deserializing primitive `long` field while using `TypeResolverBuilder`
3939
(reported by UghZan3@github)
40+
#1403: Reference-chain hints use incorrect class-name for inner classes
41+
(reported by Josh G)
4042

4143
2.8.3 (17-Sep-2016)
4244

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import com.fasterxml.jackson.annotation.JsonIgnore;
99
import com.fasterxml.jackson.core.*;
10-
import com.fasterxml.jackson.databind.util.ClassUtil;
1110

1211
/**
1312
* Checked exception used to signal fatal problems with mapping of
@@ -124,16 +123,26 @@ public String getDescription() {
124123
sb.append("UNKNOWN");
125124
} else {
126125
Class<?> cls = (_from instanceof Class<?>) ? (Class<?>)_from : _from.getClass();
127-
/* Hmmh. Although Class.getName() is mostly ok, it does look
128-
* butt-ugly for arrays. So let's use getSimpleName() instead;
129-
* but have to prepend package name too.
130-
*/
126+
// Hmmh. Although Class.getName() is mostly ok, it does look
127+
// butt-ugly for arrays.
128+
// 06-Oct-2016, tatu: as per [databind#1403], `getSimpleName()` not so good
129+
// as it drops enclosing class. So let's try bit different approach
130+
int arrays = 0;
131+
while (cls.isArray()) {
132+
cls = cls.getComponentType();
133+
++arrays;
134+
}
135+
sb.append(cls.getName());
136+
while (--arrays >= 0) {
137+
sb.append("[]");
138+
}
139+
/* was:
131140
String pkgName = ClassUtil.getPackageName(cls);
132141
if (pkgName != null) {
133142
sb.append(pkgName);
134143
sb.append('.');
135144
}
136-
sb.append(cls.getSimpleName());
145+
*/
137146
}
138147
sb.append('[');
139148
if (_fieldName != null) {
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.fasterxml.jackson.databind.deser.exc;
2+
3+
import com.fasterxml.jackson.annotation.*;
4+
5+
import com.fasterxml.jackson.databind.*;
6+
7+
public class ExceptionPathTest extends BaseMapTest
8+
{
9+
static class Outer {
10+
public Inner inner = new Inner();
11+
}
12+
13+
static class Inner {
14+
public int x;
15+
16+
@JsonCreator public static Inner create(@JsonProperty("x") int x) {
17+
throw new RuntimeException("test-exception");
18+
}
19+
}
20+
21+
/*
22+
/**********************************************************
23+
/* Test methods
24+
/**********************************************************
25+
*/
26+
27+
private final ObjectMapper MAPPER = new ObjectMapper();
28+
29+
public void testReferenceChainForInnerClass() throws Exception
30+
{
31+
String json = MAPPER.writeValueAsString(new Outer());
32+
try {
33+
MAPPER.readValue(json, Outer.class);
34+
fail("Should not pass");
35+
} catch (JsonMappingException e) {
36+
JsonMappingException.Reference reference = e.getPath().get(0);
37+
assertEquals(getClass().getName()+"$Outer[\"inner\"]",
38+
reference.toString());
39+
}
40+
}
41+
42+
public static void main(String[] args)
43+
{
44+
System.err.println("Int, full: "+Integer.TYPE.getName());
45+
}
46+
}

src/test/java/com/fasterxml/jackson/databind/deser/TestExceptionDeserialization.java renamed to src/test/java/com/fasterxml/jackson/databind/deser/exc/TestExceptionDeserialization.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fasterxml.jackson.databind.deser;
1+
package com.fasterxml.jackson.databind.deser.exc;
22

33
import java.io.IOException;
44
import java.util.*;

src/test/java/com/fasterxml/jackson/databind/deser/TestExceptionHandling.java renamed to src/test/java/com/fasterxml/jackson/databind/deser/exc/TestExceptionHandling.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fasterxml.jackson.databind.deser;
1+
package com.fasterxml.jackson.databind.deser.exc;
22

33
import java.io.*;
44

@@ -24,10 +24,7 @@ static class Bean {
2424
/* Test methods
2525
/**********************************************************
2626
*/
27-
28-
/**
29-
* Verification of [JACKSON-301]
30-
*/
27+
3128
public void testHandlingOfUnrecognized() throws Exception
3229
{
3330
UnrecognizedPropertyException exc = null;

src/test/java/com/fasterxml/jackson/databind/deser/TestExceptionHandlingWithDefaultDeserialization.java renamed to src/test/java/com/fasterxml/jackson/databind/deser/exc/TestExceptionHandlingWithDefaultDeserialization.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,37 @@
1-
package com.fasterxml.jackson.databind.deser;
1+
package com.fasterxml.jackson.databind.deser.exc;
22

33
import com.fasterxml.jackson.databind.BaseMapTest;
44
import com.fasterxml.jackson.databind.JsonMappingException;
55
import com.fasterxml.jackson.databind.ObjectMapper;
66

77
import java.io.IOException;
88

9-
public class TestExceptionHandlingWithDefaultDeserialization extends BaseMapTest {
10-
9+
public class TestExceptionHandlingWithDefaultDeserialization extends BaseMapTest
10+
{
1111
static class Foo {
12-
1312
private Bar bar;
1413

15-
public Foo() {
16-
}
14+
public Foo() { }
1715

1816
public Bar getBar() {
1917
return bar;
2018
}
2119
}
2220

2321
static class Bar {
24-
2522
private Baz baz;
2623

27-
public Bar() {
28-
}
24+
public Bar() { }
2925

3026
public Baz getBaz() {
3127
return baz;
3228
}
3329
}
3430

3531
static class Baz {
36-
3732
private String qux;
3833

39-
public Baz() {
40-
}
34+
public Baz() { }
4135

4236
public String getQux() {
4337
return qux;
@@ -48,14 +42,15 @@ public void testShouldThrowJsonMappingExceptionWithPathReference() throws IOExce
4842
// given
4943
ObjectMapper mapper = new ObjectMapper();
5044
String input = "{\"bar\":{\"baz\":{qux:\"quxValue\"))}";
45+
final String THIS = getClass().getName();
5146

5247
// when
5348
try {
5449
mapper.readValue(input, Foo.class);
5550
fail("Upsss! Exception has not been thrown.");
5651
} catch (JsonMappingException ex) {
5752
// then
58-
assertEquals("com.fasterxml.jackson.databind.deser.Foo[\"bar\"]->com.fasterxml.jackson.databind.deser.Bar[\"baz\"]",
53+
assertEquals(THIS+"$Foo[\"bar\"]->"+THIS+"$Bar[\"baz\"]",
5954
ex.getPathReference());
6055
}
6156
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fasterxml.jackson.databind.deser;
1+
package com.fasterxml.jackson.databind.deser.exc;
22

33
import com.fasterxml.jackson.annotation.JsonCreator;
44
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -53,14 +53,15 @@ public void testShouldThrowJsonMappingExceptionWithPathReference() throws IOExce
5353
// given
5454
ObjectMapper mapper = new ObjectMapper();
5555
String input = "{\"bar\":{\"baz\":{qux:\"quxValue\"))}";
56+
final String THIS = getClass().getName();
5657

5758
// when
5859
try {
5960
mapper.readValue(input, Foo.class);
6061
fail("Upsss! Exception has not been thrown.");
6162
} catch (JsonMappingException ex) {
6263
// then
63-
assertEquals("com.fasterxml.jackson.databind.deser.Foo[\"bar\"]->com.fasterxml.jackson.databind.deser.Bar[\"baz\"]",
64+
assertEquals(THIS+"$Foo[\"bar\"]->"+THIS+"$Bar[\"baz\"]",
6465
ex.getPathReference());
6566
}
6667
}

src/test/java/com/fasterxml/jackson/databind/ser/TestExceptionSerialization.java renamed to src/test/java/com/fasterxml/jackson/databind/deser/exc/TestExceptionSerialization.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fasterxml.jackson.databind.ser;
1+
package com.fasterxml.jackson.databind.deser.exc;
22

33
import java.io.IOException;
44
import java.util.*;

src/test/java/com/fasterxml/jackson/databind/ser/TestExceptionHandling.java renamed to src/test/java/com/fasterxml/jackson/databind/deser/exc/TestExceptionsDuringWriting.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fasterxml.jackson.databind.ser;
1+
package com.fasterxml.jackson.databind.deser.exc;
22

33
import java.io.*;
44
import java.util.*;
@@ -12,7 +12,7 @@
1212
* re-thrown or wrapped, depending)
1313
* with Object serialization.
1414
*/
15-
public class TestExceptionHandling
15+
public class TestExceptionsDuringWriting
1616
extends BaseMapTest
1717
{
1818
/*

0 commit comments

Comments
 (0)