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

#1288 applying JACKSON-831 on the BuilderBasedDeserializer #1295

Merged
merged 1 commit into from Jul 11, 2016
Merged

#1288 applying JACKSON-831 on the BuilderBasedDeserializer #1295

merged 1 commit into from Jul 11, 2016

Conversation

libetl
Copy link
Contributor

@libetl libetl commented Jul 11, 2016

Bug ref : #1288 (failing UT : https://gist.github.com/libetl/9c6ec1820444370c3c55670058f57426).
This fix consists in applying an old bugfix on one impl of the BeanDeserializerBase interface ( BuilderBasedDeserializer).
It will allow me to unmarshall successfully the ExternalTypeId properties on a Builder deserialized bean.

WDYT ?

Thanks for your help.

@libetl
Copy link
Contributor Author

libetl commented Jul 11, 2016

Preview of JACKSON-831 :

Deserialization of a property type resolved as an EXTERNAL_PROPERTY doesn't work
if the external type ID property is also deserialized as a property of the
object


            Key: JACKSON-831
            URL: https://jira.codehaus.org/browse/JACKSON-831
        Project: Jackson JSON Processor
     Issue Type: Bug
     Components: Deserializer

Affects Versions: 1.9.6
Reporter: Laurent Pireyn
Assignee: Tatu Saloranta

Given the following classes:

public interface Pet {}
public class Dog implements Pet {
    String name;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}
public class House {
    private String petType;
    @JsonTypeInfo(
        use = Id.NAME,
        include = As.EXTERNAL_PROPERTY,
        property = "petType"
    )
    @JsonSubTypes({
        @Type(name = "dog", value = Dog.class)
    })
    Pet pet;
    public String getPetType() {
        return petType;
    }
    public void setPetType(String petType) {
        this.petType = petType;
    }
    public Pet getPet() {
        return pet;
    }
    public void setPet(Pet pet) {
        this.pet = pet;
    }
}

Deserializing the following JSON object as an instance of the {{House}} class:

{
    "petType": "dog",
    "pet": {
        "name": "Pluto"
    }
}

throws the following exception:

org.codehaus.jackson.map.JsonMappingException: Missing external type id property
'petType

If the {{petType}} property is removed from the {{House}} class, the
deserialization succeeds.
It seems that a JSON property already mapped to an actual property cannot be
used as type ID anymore.

@cowtowncoder
Copy link
Member

Sounds good to me and I know there have been cases where changes to one have been missing from the other.

@cowtowncoder cowtowncoder merged commit c9909b2 into FasterXML:master Jul 11, 2016
@cowtowncoder
Copy link
Member

Thank you for tracking this down! I'll merge it to 2.7 as well when I get a chance.

@libetl
Copy link
Contributor Author

libetl commented Jul 11, 2016

Great, thanks.

@libetl libetl deleted the bugfix/externalTypeId1288 branch July 11, 2016 21:24
@cowtowncoder cowtowncoder added this to the 2.8.1 milestone Jul 12, 2016
@cowtowncoder
Copy link
Member

Thank you very much for tracking & resolving this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants