I have the following xml:
<?xml version="1.0"?>
<configuration>
</configurations>
When I read this xml using XMLMapper as below:
XmlMapper xmlMapper = new XmlMapper();
List<Map<String, Object>> entries = xmlMapper.readValue(new File(xmlFileName), List.class);
I get null pointer exception with the following call stack:
java.lang.NullPointerException at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer.deserialize(UntypedObjectDeserializer.java:162) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:227) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:204) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:23) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2993) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2052) .... ....
Even when XML does not have values in between tags, it is still valid, so I think the function should return empty list not NPE.
I found that it is a bug in the implementation and for time being I handled the exception safely to solve this problem.