-
-
Notifications
You must be signed in to change notification settings - Fork 230
Closed
Milestone
Description
I've hit a rather nasty problem when deserializing some XML, which seems to be caused by the order the attributes appear on an xml element. For exemple <Foo type=\"bad\" data=\"dummy\"><bar><bar>FOOBAR</bar></bar></Foo>
parses fine, but inverting type
and data
attributes' order result in this weird exception:
com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
at [Source: java.io.StringReader@42787d6a; line: 1, column: 36] (through reference chain: FooBad["bar"])
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:164)
at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:698)
at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:694)
at com.fasterxml.jackson.databind.deser.std.StringCollectionDeserializer.handleNonArray(StringCollectionDeserializer.java:210)
at com.fasterxml.jackson.databind.deser.std.StringCollectionDeserializer.deserialize(StringCollectionDeserializer.java:164)
at com.fasterxml.jackson.databind.deser.std.StringCollectionDeserializer.deserialize(StringCollectionDeserializer.java:154)
at com.fasterxml.jackson.databind.deser.std.StringCollectionDeserializer.deserialize(StringCollectionDeserializer.java:1)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:538)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:99)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:242)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:155)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:126)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:110)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:81)
at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:132)
at com.fasterxml.jackson.databind.deser.impl.TypeWrappedDeserializer.deserialize(TypeWrappedDeserializer.java:41)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3008)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2113)
I've also noted that this doesn't cause problem when the property is not a List. I'll attach a unit test shortly.
I've debugged a little bit and it seems that because the type
property is not the first encountered during parsing there's some buffering (with TokenBuffer
) involved, which doesn't seem to play well with the Collection deserializer. This might also be related to the virtual wrapping necessary for collections?
Metadata
Metadata
Assignees
Labels
No labels