[jdom-interest] (Small) Bug in AttributeList.clear()

Benjamin Broll benjamin.broll at massp.com
Fri Jun 13 02:19:31 PDT 2003


Hi everyone,

currently I'm heavily working with Attributes and discovered a little
bug in the AttributeList.clear() implementation.

The method just clears the content of the list but does not reset its
size to 0. Thus, when adding two Attributes after the clear() call, a
NullPointerException is thrown from the 

indexOf(String name, Namespace namespace)

method at when the second Attribute is added.

Some sample code to reproduce the problem is:

Element e = new Element("myname");
e.setAttribute("my", "attribute");
e.setAttribute("your", "attribute");
e.setAttribute("his", "attribute");

e.getAttributes().clear();
e.setAttribute("my", "attribute");
e.setAttribute("your", "attribute");   // <-- NullPointerException

Hope that helps,

Benjamin






More information about the jdom-interest mailing list