Fix #1383
diff --git a/release-notes/VERSION b/release-notes/VERSION
index 520b048..1c38d3f 100644
--- a/release-notes/VERSION
+++ b/release-notes/VERSION
@@ -15,6 +15,7 @@
#1368: Problem serializing `JsonMappingException` due to addition of non-ignored
`processor` property (added in 2.7)
(reported, suggesed fix by Josh C)
+#1383: Problem with `@JsonCreator` with 1-arg factory-method, implicit param names
2.7.7 (27-Aug-2016)
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java b/src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java
index 40a3c18..fd1972e 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java
@@ -683,7 +683,11 @@
if (!useProps) { // not property based but delegating
/*boolean added=*/ _handleSingleArgumentFactory(config, beanDesc, vchecker, intr, creators,
factory, isCreator);
- // otherwise just ignored
+ // 23-Sep-2016, tatu: [databind#1383]: Need to also sever link to avoid possible
+ // later problems with "unresolved" constructor property
+ if (argDef != null) {
+ ((POJOPropertyBuilder) argDef).removeConstructors();
+ }
continue;
}
// fall through if there's name
diff --git a/src/test/java/com/fasterxml/jackson/databind/creators/SingleArgCreatorTest.java b/src/test/java/com/fasterxml/jackson/databind/creators/SingleArgCreatorTest.java
index e075151..04cb86f 100644
--- a/src/test/java/com/fasterxml/jackson/databind/creators/SingleArgCreatorTest.java
+++ b/src/test/java/com/fasterxml/jackson/databind/creators/SingleArgCreatorTest.java
@@ -115,7 +115,30 @@
public String value() { return value; }
}
+
+ static class XY {
+ public int x, y;
+ }
+ // [databind#1383]
+ static class SingleArgWithImplicit {
+ protected XY _value;
+
+ private SingleArgWithImplicit() {
+ throw new Error("Should not get called");
+ }
+ private SingleArgWithImplicit(XY v, boolean bogus) {
+ _value = v;
+ }
+
+ @JsonCreator
+ public static SingleArgWithImplicit from(XY v) {
+ return new SingleArgWithImplicit(v, true);
+ }
+
+ public XY getFoobar() { return _value; }
+ }
+
/*
/**********************************************************
/* Test methods
@@ -147,7 +170,7 @@
StringyBeanWithProps bean = mapper.readValue("{\"value\":\"x\"}", StringyBeanWithProps.class);
assertEquals("x", bean.getValue());
}
-
+
// [databind#714]
public void testSingleExplicitlyNamedButDelegating() throws Exception
{
@@ -171,5 +194,18 @@
assertNotNull(bean2);
assertEquals("def", bean2.value());
}
+
+ // [databind#1383]
+ public void testSingleImplicitDelegating() throws Exception
+ {
+ final ObjectMapper mapper = new ObjectMapper();
+ mapper.setAnnotationIntrospector(new MyParamIntrospector("value"));
+ SingleArgWithImplicit bean = mapper.readValue(aposToQuotes("{'x':1,'y':2}"),
+ SingleArgWithImplicit.class);
+ XY v = bean.getFoobar();
+ assertNotNull(v);
+ assertEquals(1, v.x);
+ assertEquals(2, v.y);
+ }
}