diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java index bf2b0bbf61..fabee2caaa 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java @@ -947,7 +947,6 @@ protected Object deserializeUsingPropertyBasedWithUnwrapped(JsonParser p, Deseri p.setCurrentValue(bean); // if so, need to copy all remaining tokens into buffer while (t == JsonToken.FIELD_NAME) { - p.nextToken(); // to skip name tokens.copyCurrentStructure(p); t = p.nextToken(); } diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/TestBasicAnnotations.java b/src/test/java/com/fasterxml/jackson/databind/deser/TestBasicAnnotations.java index 17be5cfcff..097656c8d7 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/TestBasicAnnotations.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/TestBasicAnnotations.java @@ -61,6 +61,32 @@ final static class SizeClassSetter3 @JsonDeserialize public void x(int value) { _x = value; } } + static class Issue2088Bean { + int x; + int y; + + @JsonUnwrapped + Issue2088UnwrappedBean w; + + public Issue2088Bean(@JsonProperty("x") int x, @JsonProperty("y") int y) { + this.x = x; + this.y = y; + } + + public void setW(Issue2088UnwrappedBean w) { + this.w = w; + } + } + + static class Issue2088UnwrappedBean { + int a; + int b; + + public Issue2088UnwrappedBean(@JsonProperty("a") int a, @JsonProperty("b") int b) { + this.a = a; + this.b = b; + } + } /// Classes for testing Setter discovery with inheritance static class BaseBean @@ -181,6 +207,16 @@ public void testIssue442PrivateUnwrapped() throws Exception assertEquals(5, bean.w.i); } + // [databind#2088] + public void testIssue2088UnwrappedFieldsAfterLastCreatorProp() throws Exception + { + Issue2088Bean bean = MAPPER.readValue("{\"x\":1,\"a\":2,\"y\":3,\"b\":4}", Issue2088Bean.class); + assertEquals(1, bean.x); + assertEquals(2, bean.w.a); + assertEquals(3, bean.y); + assertEquals(4, bean.w.b); + } + /* /********************************************************** /* Test methods, annotations disabled