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

SAX Parser throws InternalError on invalid XML

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 8u102
    • Fix Version/s: None
    • Component/s: xml

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_102"
      Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      SAX parser with some features throws java.lang.InternalError when parsing invalid XML.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the test case.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Parser throws SAXException.
      ACTUAL -
      Parser throws java.lang.InternalError.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class XmlErrorTest {

          public static void main(String[] args) {
              try {
                  String invalidXml = "<a>";
                  SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
                  saxParserFactory.setFeature("http://apache.org/xml/features/continue-after-fatal-error", true);
                  SAXParser parser = saxParserFactory.newSAXParser();
                  parser.parse(new InputSource(new StringReader(invalidXml)), new DefaultHandler() {
                      @Override
                      public void fatalError(SAXParseException e) throws SAXException {
                          System.err.printf("%s%n", e.getMessage());
                      }
                  });
              } catch (Throwable e) {
                  e.printStackTrace();
              }
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use apache Xerces instead of built-in parser.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                psonal Pallavi Sonal (Inactive)
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: