Skip to content

Exception on deserializing empty element with an xsi attribute on non String type. #184

Closed
@chikim79

Description

@chikim79

#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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions