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

BeanDeserializerBase (2.6.0 regression): only update creatorProps with CreatorPropertys #881

Merged
merged 1 commit into from
Jul 29, 2015
Merged
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 @@ -481,7 +481,7 @@ public void resolve(DeserializationContext ctxt)
// 18-May-2015, tatu: _Should_ start with consistent set. But can we really
// fully count on this? May need to revisit in future; seems to hold for now.
for (int i = 0, len = creatorProps.length; i < len; ++i) {
if (creatorProps[i] == origProp) {
if (creatorProps[i] == origProp && prop instanceof CreatorProperty) {
creatorProps[i] = prop;
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.fasterxml.jackson.databind.creators;

import java.io.IOException;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
* @author dharaburda
*/
public class TestCreatorsWithIdentity extends BaseMapTest {

@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id", scope=Parent.class)
public static class Parent {
@JsonProperty("id")
String id;

@JsonProperty
String parentProp;

@JsonCreator
public Parent(@JsonProperty("parentProp") String parentProp) {
this.parentProp = parentProp;
}
}


public static class Child {
@JsonProperty
Parent parent;

@JsonProperty
String childProp;

@JsonCreator
public Child(@JsonProperty("parent") Parent parent, @JsonProperty("childProp") String childProp) {
this.parent = parent;
this.childProp = childProp;
}
}

private static final ObjectMapper JSON_MAPPER = new ObjectMapper();

public void test() throws IOException {
String parentStr = "{\"id\" : \"1\", \"parentProp\" : \"parent\"}";
String childStr = "{\"childProp\" : \"child\", \"parent\" : " + parentStr + "}";
Parent parent = JSON_MAPPER.readValue(parentStr, Parent.class);
Child child = JSON_MAPPER.readValue(childStr, Child.class);
}

}