Skip to content

Commit 08cd242

Browse files
committed
Merge branch '2.8'
2 parents 5b6ce55 + f70ae5d commit 08cd242

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

src/test/java/com/fasterxml/jackson/failing/IgnoredCreatorProperty1572Test.java

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import com.fasterxml.jackson.databind.BaseMapTest;
66
import com.fasterxml.jackson.databind.ObjectMapper;
7+
import com.fasterxml.jackson.databind.introspect.*;
78

89
public class IgnoredCreatorProperty1572Test extends BaseMapTest
910
{
@@ -15,15 +16,37 @@ static class InnerTest
1516

1617
static class OuterTest
1718
{
18-
InnerTest inner;
19+
InnerTest innerTest;
1920

2021
@JsonIgnore
21-
public String otherStr;
22+
String otherOtherStr;
2223

2324
@JsonCreator
24-
public OuterTest(@JsonProperty("inner") InnerTest inner,
25-
@JsonProperty("otherOtherStr") String otherStr) {
26-
this.inner = inner;
25+
public OuterTest(/*@JsonProperty("innerTest")*/ InnerTest inner,
26+
/*@JsonProperty("otherOtherStr")*/ String otherStr) {
27+
this.innerTest = inner;
28+
}
29+
}
30+
31+
static class ImplicitNames extends JacksonAnnotationIntrospector
32+
{
33+
private static final long serialVersionUID = 1L;
34+
35+
@Override
36+
public String findImplicitPropertyName(AnnotatedMember member) {
37+
if (member instanceof AnnotatedParameter) {
38+
// A placeholder for legitimate property name detection
39+
// such as what the JDK8 module provides
40+
AnnotatedParameter param = (AnnotatedParameter) member;
41+
switch (param.getIndex()) {
42+
case 0:
43+
return "innerTest";
44+
case 1:
45+
return "otherOtherStr";
46+
default:
47+
}
48+
}
49+
return null;
2750
}
2851
}
2952

@@ -33,16 +56,18 @@ public OuterTest(@JsonProperty("inner") InnerTest inner,
3356
/********************************************************
3457
*/
3558

36-
private final ObjectMapper MAPPER = new ObjectMapper();
37-
3859
// [databind#1572]
3960
public void testIgnoredCtorParam() throws Exception
4061
{
62+
final ObjectMapper mapper = new ObjectMapper();
63+
mapper.setAnnotationIntrospector(new ImplicitNames());
4164
String JSON = aposToQuotes("{'innerTest': {\n"
4265
+"'str':'str',\n"
4366
+"'otherStr': 'otherStr'\n"
4467
+"}}\n");
45-
OuterTest result = MAPPER.readValue(JSON, OuterTest.class);
68+
OuterTest result = mapper.readValue(JSON, OuterTest.class);
4669
assertNotNull(result);
70+
assertNotNull(result.innerTest);
71+
assertEquals("otherStr", result.innerTest.otherStr);
4772
}
4873
}

0 commit comments

Comments
 (0)