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 Creator2438(@sonProperty"value") int v)15 public Creator2438(@JsonProperty("value") int v) { 16 //System.err.println("DEBUG: value set as "+v); 17 value = v; 18 } 19 accessValue()20 public int accessValue() { return value; } 21 22 // This or visible (public) setter are required to show the issue setValue(int v)23 public void setValue(int v) { value = v; } 24 } 25 26 private final ObjectMapper MAPPER = newJsonMapper(); 27 testCreator2438()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 } 39