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 on non String type. #184

Closed
chikim79 opened this issue Jan 22, 2016 · 4 comments

Comments

@chikim79
Copy link

#167 fixed the issue with the String type.

It is still happening on a Double type and possibly others.
xsi attribute is giving errors on Double type regardless of the existence of the value.
e.g. xsi:nil="false" with value and xsi:nil="true" with empty value.

<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"/> <!-- fixed in 2.7 -->
       <e xsi:nil="false">1.2</c> <!-- throws exception -->
       <f xsi:nil="true"/> <!-- throws exception -->
</a>
public class A {
    String b;
    String c;
    String d;
    Double e;
    Double f;
    ...
}
com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.Double out of START_OBJECT token
 at [Source: /NFL/shield/esb/input/A.xml; line: 5, column: 2] (through reference chain: com.nfl.dm.shield.ingester.stats.domain.A["e"])
    at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:216)
    at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:873)
    at com.fasterxml.jackson.databind.deser.std.StdDeserializer._parseDouble(StdDeserializer.java:707)
    at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$DoubleDeserializer.deserialize(NumberDeserializers.java:386)
    at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$DoubleDeserializer.deserialize(NumberDeserializers.java:371)
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:490)
    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:95)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:260)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3788)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2673)
@cowtowncoder
Copy link
Member

Thank you for reporting this. I hope this can be fixed; there are some special translations done for String handling, but it should be possible to figure out something similar for other simple scalar types: numbers, coolean.

@nyilmaz
Copy link

nyilmaz commented May 15, 2017

BigDecimal ends up the same. Any updates on this?

com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.math.BigDecimal out of START_OBJECT token for;

<PointsUsedYTL xsi:nil="true"/>

@cowtowncoder
Copy link
Member

@nyilmaz PRs welcome.

@cowtowncoder
Copy link
Member

Created #354 for general support of xsi:nil.

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