[jdom-interest] Bug in Document.java
Jools
jools at jools.org
Sun Oct 7 10:37:53 PDT 2001
Hi
A bug exists in Document.java where a ProcessingInstruction can be
removed
from a Document but the parentage is not set to null, should it be
removed.
Attached is a demonstraction of the bug (DocBug.java) and a diff which
will fix the problem taken against the current version in CVS.
--Jools
-------------- next part --------------
Index: Document.java
===================================================================
RCS file: /home/cvspublic/jdom/src/java/org/jdom/Document.java,v
retrieving revision 1.44
diff -r1.44 Document.java
575c575,580
< return content.remove(pi);
---
> if (content.remove(pi)) {
> pi.setDocument(null);
> return true;
> } else {
> return false;
> }
-------------- next part --------------
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.ProcessingInstruction;
public class DocBug {
public static void main(String[] args) {
Document doc = new Document(new Element("bug"));
ProcessingInstruction foo = new ProcessingInstruction("foo", "data");
// Adding sets the parent.
doc.addContent(foo);
// Removing __should__ set the parent to null.
doc.removeContent(foo);
// This should not throw an exception.
doc.addContent(foo);
}
}
More information about the jdom-interest
mailing list