File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
src/test/java/com/fasterxml/jackson/failing Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments