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

Exception on deserializing empty element with an xsi attribute. #167

Closed
chikim79 opened this issue Nov 6, 2015 · 4 comments
Closed

Exception on deserializing empty element with an xsi attribute. #167

chikim79 opened this issue Nov 6, 2015 · 4 comments
Milestone

Comments

@chikim79
Copy link

chikim79 commented Nov 6, 2015

Jackson XML fails with following exception when trying to deserialize an empty element with xsi attribute.

<a xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <b/>  <!-- works fine -->
       <c xsi:nil="false">0920</c> <!-- works fine -->
       <d xsi:nil="true"/> <!-- throws exception -->
</a>
public class A {
    String b;
    String c;
    String d;
    ...
}
com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token
 at [Source: java.io.StringReader@7862f584; line: 4, column: 8] (through reference chain: A["d"])
    at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148)
    at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:854)
    at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:62)
    at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:11)
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:520)
    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:95)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:256)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3731)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2724)

I tried looking at the code, but couldn't see a straight forward way to fix the issue.

@Typografikon
Copy link

I have the same problem, any idea to deal with it?

@chikim79
Copy link
Author

chikim79 commented Dec 5, 2015

I regretably ended up using a different xml parser. Still I would love for Jackson to fix this.

@cowtowncoder
Copy link
Member

Looking into this now. Can't fix in 2.6, but might be able to fix in 2.7.

cowtowncoder added a commit that referenced this issue Dec 24, 2015
@cowtowncoder cowtowncoder added this to the 2.7.0-rc3 milestone Dec 24, 2015
@cowtowncoder
Copy link
Member

And yes, figured out a way to get it fixed.

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

No branches or pull requests

3 participants