JDK-7157610 : NullPointerException occurs when parsing XML doc
  • Type: Bug
  • Component: xml
  • Sub-Component: javax.xml.parsers
  • Affected Version: 7u2
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86
  • Submitted: 2012-03-29
  • Updated: 2013-08-20
  • Resolved: 2012-06-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 JDK 8
6u65Fixed 7u6 b15Fixed 8Fixed
Related Reports
Relates :  
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.
11-06-2012