Details
-
Bug
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
jcrdiff-1.02.03
Description
Xerces only defines/provides an SAX Attributes localName when using namespace processing (in contrast to default Java JRE SAX XML parsing...).
This causes a NullPointer exception in jcrdiff:
java.lang.NullPointerException
at java.util.TreeMap.compare(TreeMap.java:1188)
at java.util.TreeMap.put(TreeMap.java:531)
at org.onehippo.cms7.jcrdiff.content.mem.MemTreeNode.setProperty(MemTreeNode.java:151)
at org.onehippo.cms7.jcrdiff.content.mem.MemTreeNode.setProperty(MemTreeNode.java:34)
at org.onehippo.cms7.jcrdiff.content.xml.SaxContentHandler.endElement(SaxContentHandler.java:147)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
This NPE is thus caused by the jcrdiff SaxContentHandler#parseAttributes method, which currently assumes the attribute localName always is defined.
Note: the XML parsed here is also produced by jcrdiff itself, which does NOT use any qualified/namespaced attributes...
To fix this, the #parseAttributes method can/must instead use the Attributes#getQName method, which is safe and should provide the same attribute name value in this context (because no qualified/namespaced attributes are generated by jcrdiff in the first place).