-
-
Notifications
You must be signed in to change notification settings - Fork 230
Closed
Milestone
Description
I found a problem with deserializing empty classes in combination with polymorphism. The issue can also be found on SO: http://stackoverflow.com/questions/33722369/jackson-xml-deserializing-empty-classes-and-polymorphism
The problem happens both with JAXB and Jackson XML annotations. I pasted the XML example below:
public static class Data {
@XmlElement(name = "name")
private String name;
@XmlElements({
@XmlElement(type = EmptyProxy.class, name = "empty")
})
private Proxy proxy;
}
public interface Proxy {
}
@XmlType(name = "empty")
public static class EmptyProxy implements Proxy {
}
public static void main(String[] a) throws IOException {
final ObjectMapper mapper = new XmlMapper()/*.registerModule(new JacksonXmlModule())*/.registerModule(new JaxbAnnotationModule());
final Data data = mapper.readValue("<data><name>my-name</name><proxy><empty></empty></proxy></data>", Data.class);
}
This gives the following exeption:
Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of Test$EmptyProxy out of VALUE_NULL token
at [Source: java.io.StringReader@27c20538; line: 1, column: 49] (through reference chain: Data["proxy"])
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148)
Metadata
Metadata
Assignees
Labels
No labels