Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't skip the FIELD_NAME following the last creator property during @JsonUnwrapped property-based deserialization #2089

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down