Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7157610

NullPointerException occurs when parsing XML doc

    Details

    • Subcomponent:
    • Resolved In Build:
      b15
    • CPU:
      x86
    • OS:
      windows_7
    • Verification:
      Verified

      Backports

        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.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  joehw Joe Wang
                  Reporter:
                  xiaojuzh Xiaojun Zhang (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: