Bug 29853 - NPE parsing certain plugin.xml files from Eclipse
Summary: NPE parsing certain plugin.xml files from Eclipse
Status: RESOLVED FIXED
Alias: None
Product: classpath
Classification: Unclassified
Component: xml (show other bugs)
Version: unspecified
: P3 normal
Target Milestone: ---
Assignee: chris burdess
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-15 20:48 UTC by Ben Konrath
Modified: 2006-12-06 19:24 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
sample plugin.xml file from Eclipse (146 bytes, application/xml)
2006-11-15 20:49 UTC, Ben Konrath
Details
small test app that causes NPE (750 bytes, text/plain)
2006-11-15 20:50 UTC, Ben Konrath
Details
patch to fix NPE and add small optimization to mutation event propagation (531 bytes, patch)
2006-11-18 02:28 UTC, Ben Konrath
Details | Diff
updated patch (728 bytes, patch)
2006-12-06 16:37 UTC, Ben Konrath
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Konrath 2006-11-15 20:48:39 UTC
I get a NPE parsing certain plugin.xml files from Eclipse with libgcj from FC-6:

% java PluginXMLHandler 
org.xml.sax.SAXParseException
   at gnu.xml.stream.SAXParser.parse(libgcj.so.7rh)
   at javax.xml.parsers.SAXParser.parse(libgcj.so.7rh)
   at javax.xml.parsers.SAXParser.parse(libgcj.so.7rh)
   at PluginXMLHandler.main(PluginXMLHandler.java:31)
Caused by: java.lang.NullPointerException
   at gnu.xml.dom.DomNode.dispatchEvent(libgcj.so.7rh)
   at gnu.xml.dom.DomAttr.mutating(libgcj.so.7rh)
   at gnu.xml.dom.DomAttr.setNodeValue(libgcj.so.7rh)
   at gnu.xml.dom.DomElement.setAttribute(libgcj.so.7rh)
   at PluginXMLHandler.startElement(PluginXMLHandler.java:44)
   at gnu.xml.stream.SAXParser.parse(libgcj.so.7rh)
   ...3 more
%

I do not get this NPE with Sun's VM:

% jdk1.5.0_09/bin/java PluginXMLHandler
%

I believe this is a problem with Classpath HEAD as well. I will attach a test xml file and small parsing app.
Comment 1 Ben Konrath 2006-11-15 20:49:39 UTC
Created attachment 12625 [details]
sample plugin.xml file from Eclipse
Comment 2 Ben Konrath 2006-11-15 20:50:58 UTC
Created attachment 12626 [details]
small test app that causes NPE
Comment 3 Ben Konrath 2006-11-18 02:28:28 UTC
Created attachment 12634 [details]
patch to fix NPE and add small optimization to mutation event propagation

I think this patch should fix the problem. The change to DomNode.java fixes the actual NPE and the change to DomAttr.java are a mini optimization (don't report a mutation if the oldValue and the newValue are the same value). I'm not sure if the optimization is a good idea because it will throw a NPE if newValue is null.

Chris, it would be cool if you could check this over when you have a chance - I'd like to know if these solutions are going to work. Thanks. 

I will be putting a workaround in Fedora's Eclipse packages so that the PDE will work with GCJ until this is fixed.
Comment 4 chris burdess 2006-12-06 11:41:21 UTC
Ben, this patch looks good but for the potential NPE you describe. Instead of "newValue.equals(oldValue)" please use "equal(newValue, oldValue)" (defined in DomNode) and commit.
Comment 5 Ben Konrath 2006-12-06 16:37:21 UTC
Created attachment 12756 [details]
updated patch

I don't have commit access to Classpath so feel free to commit this. I updated the patch with your suggestion and included a ChangeLog entry. Thanks.
Comment 6 cvs-commit@developer.classpath.org 2006-12-06 18:38:32 UTC
Subject: Bug 29853

CVSROOT:	/cvsroot/classpath
Module name:	classpath
Changes by:	Chris Burdess <dog>	06/12/06 18:38:06

Modified files:
	.              : ChangeLog 
	gnu/xml/dom    : DomAttr.java DomNode.java 

Log message:
	2006-12-06  Ben Konrath  <bkonrath@redhat.com>
	
		Fixes PR 29853.
		* gnu/xml/dom/DomAttr.java: Don't report mutation if oldValue and
		newValue are the same.
		* gnu/xml/dom/DomNode.java: Set parent if null during mutation.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.8931&r2=1.8932
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/dom/DomAttr.java?cvsroot=classpath&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/dom/DomNode.java?cvsroot=classpath&r1=1.16&r2=1.17



Comment 7 chris burdess 2006-12-06 18:39:25 UTC
Patch committed.
Comment 8 Ben Konrath 2006-12-06 19:24:36 UTC
Thanks Chris.
Comment 9 cvs-commit@developer.classpath.org 2006-12-08 10:30:40 UTC
Subject: Bug 29853

CVSROOT:	/cvsroot/classpath
Module name:	classpath
Branch:		generics-branch
Changes by:	Mark Wielaard <mark>	06/12/08 10:30:10

Modified files:
	.              : ChangeLog 
	gnu/xml/dom    : DomAttr.java DomNode.java 
	gnu/xml/stream : SAXParser.java XMLStreamWriterImpl.java 
	javax/xml/parsers: DocumentBuilderFactory.java 
	javax/xml/validation: SchemaFactory.java 

Log message:
	2006-12-06  Ben Konrath  <bkonrath@redhat.com>
	
	       Fixes PR 29853.
	       * gnu/xml/dom/DomAttr.java: Don't report mutation if oldValue and
	       newValue are the same.
	       * gnu/xml/dom/DomNode.java: Set parent if null during mutation.
	
	2006-12-06  Chris Burdess  <dog@gnu.org>
	
	       Fixes PR 29272.
	       * javax/xml/parsers/DocumentBuilderFactory.java: Fix broken Javadoc.
	       * gnu/xml/stream/SAXParser.java: Fix file descriptor leak.
	
	2006-12-06  Chris Burdess  <dog@gnu.org>
	
	       Fixes PR 29264.
	       * gnu/xml/stream/XMLStreamWriterImpl.java: Allow arbitrary text in
	       writeDTD method.
	
	2006-12-056  Chris Burdess  <dog@gnu.org>
	
	       Fixes PR 28816.
	       * javax/xml/validation/SchemaFactory.java: Use correct algorithm to
	       discover schema factory implementation class.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&only_with_tag=generics-branch&r1=1.2386.2.358&r2=1.2386.2.359
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/dom/DomAttr.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.1.2.3&r2=1.1.2.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/dom/DomNode.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.1.2.10&r2=1.1.2.11
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/stream/SAXParser.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.14.2.4&r2=1.14.2.5
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/stream/XMLStreamWriterImpl.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.1.2.4&r2=1.1.2.5
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/xml/parsers/DocumentBuilderFactory.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.1.2.5&r2=1.1.2.6
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/xml/validation/SchemaFactory.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.1.2.5&r2=1.1.2.6



Comment 10 cvs-commit@developer.classpath.org 2006-12-08 10:32:26 UTC
Subject: Bug 29853

CVSROOT:	/cvsroot/classpath
Module name:	classpath
Branch:		classpath-0_93-branch
Changes by:	Mark Wielaard <mark>	06/12/08 10:31:50

Modified files:
	.              : ChangeLog 
	gnu/xml/dom    : DomAttr.java DomNode.java 
	gnu/xml/stream : SAXParser.java XMLStreamWriterImpl.java 
	javax/xml/parsers: DocumentBuilderFactory.java 
	javax/xml/validation: SchemaFactory.java 

Log message:
	2006-12-06  Ben Konrath  <bkonrath@redhat.com>
	
	       Fixes PR 29853.
	       * gnu/xml/dom/DomAttr.java: Don't report mutation if oldValue and
	       newValue are the same.
	       * gnu/xml/dom/DomNode.java: Set parent if null during mutation.
	
	2006-12-06  Chris Burdess  <dog@gnu.org>
	
	       Fixes PR 29272.
	       * javax/xml/parsers/DocumentBuilderFactory.java: Fix broken Javadoc.
	       * gnu/xml/stream/SAXParser.java: Fix file descriptor leak.
	
	2006-12-06  Chris Burdess  <dog@gnu.org>
	
	       Fixes PR 29264.
	       * gnu/xml/stream/XMLStreamWriterImpl.java: Allow arbitrary text in
	       writeDTD method.
	
	2006-12-056  Chris Burdess  <dog@gnu.org>
	
	       Fixes PR 28816.
	       * javax/xml/validation/SchemaFactory.java: Use correct algorithm to
	       discover schema factory implementation class.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&only_with_tag=classpath-0_93-branch&r1=1.8897.2.14&r2=1.8897.2.15
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/dom/DomAttr.java?cvsroot=classpath&only_with_tag=classpath-0_93-branch&r1=1.3&r2=1.3.12.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/dom/DomNode.java?cvsroot=classpath&only_with_tag=classpath-0_93-branch&r1=1.16&r2=1.16.2.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/stream/SAXParser.java?cvsroot=classpath&only_with_tag=classpath-0_93-branch&r1=1.21&r2=1.21.4.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/stream/XMLStreamWriterImpl.java?cvsroot=classpath&only_with_tag=classpath-0_93-branch&r1=1.5&r2=1.5.12.1
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/xml/parsers/DocumentBuilderFactory.java?cvsroot=classpath&only_with_tag=classpath-0_93-branch&r1=1.5&r2=1.5.10.1
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/xml/validation/SchemaFactory.java?cvsroot=classpath&only_with_tag=classpath-0_93-branch&r1=1.5&r2=1.5.6.1