Skip to content

Commit c0139ee

Browse files
committed
Add failing test for #2438
1 parent ae7c1e5 commit c0139ee

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
import com.fasterxml.jackson.databind.*;
7+
8+
// for [databind#2438]
9+
public class CreatorFallback2438Test extends BaseMapTest
10+
{
11+
static class Creator2438 {
12+
int value;
13+
14+
@JsonCreator
15+
public Creator2438(@JsonProperty("value") int v) {
16+
//System.err.println("DEBUG: value set as "+v);
17+
value = v;
18+
}
19+
20+
public int accessValue() { return value; }
21+
22+
// This or visible (public) setter are required to show the issue
23+
public void setValue(int v) { value = v; }
24+
}
25+
26+
private final ObjectMapper MAPPER = newJsonMapper();
27+
28+
public void testCreator2438() throws Exception
29+
{
30+
// note: by default, duplicate-detection not enabled, so should not
31+
// throw exception. But should also NOT apply second value because
32+
// field/setter should NOT be used in case there is already creator property
33+
Creator2438 value = MAPPER.readValue(aposToQuotes(
34+
"{'value':1, 'value':2}"),
35+
Creator2438.class);
36+
assertEquals(1, value.accessValue());
37+
}
38+
}

0 commit comments

Comments
 (0)