United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7157610 NullPointerException occurs when parsing XML doc
JDK-7157610 : NullPointerException occurs when parsing XML doc

Details
Type:
Bug
Submit Date:
2012-03-29
Status:
Closed
Updated Date:
2012-06-28
Project Name:
JDK
Resolved Date:
2012-06-28
Component:
xml
OS:
windows_7
Sub-Component:
javax.xml.parsers
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
7u2
Fixed Versions:
7u6 (b15)

Related Reports
Backport:
Relates:

Sub Tasks

Description
The problem is found in JAXP RI 1.4.5.

If setFeature("http://apache.org/xml/features/disallow-doctype-decl", true) is set on SAXParserFactory object, XMLReader object or DocumentBuilderFactory object, NullPointerException will be thrown when parsing XML document that has DOCTYPE declaration.

The steps of using the attached test program to reproduce:

1. unzip 001.zip
2. cd TP folder
3. launch go.bat
4. The file result.txt shows NullPointerException

The test program expects org.xml.sax.SAXParseException as follows.

-----
SAXParserFactory: OK
XMLReader: OK
DocumentBuilderFactory: OK
-----

If it is executed on JAXP RI 1.4.5, however, the following NullPointerException will be thrown.

-----
SAXParserFactory: NG  illegal message text
java.lang.NullPointerException
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDProcessor.startDTD(XMLDTDProcessor.java:677)
        :
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:341)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:277)
at parse.set_SAXParserFactory(parse.java:33)
at parse.main(parse.java:16)
XMLReader: NG  illegal message text
java.lang.NullPointerException
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDProcessor.startDTD(XMLDTDProcessor.java:677)
        :
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1176)
at parse.set_XMLReader(parse.java:53)
at parse.main(parse.java:17)
DocumentBuilderFactory: NG  illegal message text
java.lang.NullPointerException
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDProcessor.startDTD(XMLDTDProcessor.java:677)
        :
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:180)
at parse.set_DocumentBuilderFactory(parse.java:74)
at parse.main(parse.java:18)
-----

The diff for the fix is under src folder.

                                    

Comments
EVALUATION

The issue was introduced by the change in SupportDTD.
                                     
2012-06-11



Hardware and Software, Engineered to Work Together