NPE in Element.setAttribute(...) - possible bug

View: New views
1 Messages — Rating Filter:   Alert me  

NPE in Element.setAttribute(...) - possible bug

by Karianne Berg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hello list,

 

I’m using JDOM for my project, and I think I have found a bug in the Element.setAttribute(…) method. If Element.setAttribute(String, String, Namespace) is called with a namespace that is null, a NullPointerException is thrown. Here is the relevant part of the stacktrace:

 

java.lang.NullPointerException

                at org.jdom.AttributeList.indexOf(AttributeList.java:378)

                at org.jdom.AttributeList.get(AttributeList.java:366)

                at org.jdom.Element.getAttribute(Element.java:983)

                at org.jdom.Element.setAttribute(Element.java:1157)

 

Elements, however, have the behavior that if you pass in a null Namespace to the constructor, the namespace is set to Namespace.NO_NAMESPACE. I think it is logical that the behavior should be the same in attributes. If the list agrees that this is in fact a bug, I would be happy to provide a patch for this – it seems to be quite trivial to fix.

 

Best regards,

Karianne Berg


_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...
LightInTheBox - Buy quality products at wholesale price!