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

StAX implementation not spec compliant - breaks RI compliant apps

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 6
    • 6
    • xml
    • b92
    • x86
    • linux
    • Verified

      FULL PRODUCT VERSION :
      java version "1.6.0-beta2"
      Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86)
      Java HotSpot(TM) Client VM (build 1.6.0-beta2-b86, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Linux wh58-307 2.6.16.18 #1 SMP PREEMPT Tue May 30 20:43:33 MEST 2006 i686 athlon i386 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      StAX implementation validates input even if the XMLInputFactory has been instructed to not validate the content, which is read. This is not spec compliant and breaks existing applications, which work without any problems using Bea/Codehaus StAX RI implementation.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Read an XML file, whoms DOCTYPE system id points to a none-existing dtd file and set the XMLInputFactory.IS_VALIDATING to false.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      One can parse the file without any problems.
      ACTUAL -
      javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,100]
      Message: /dev/null/action.dtd (No such file or directory)
      at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:540)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      String root = "root";
      XMLInputFactory xif = XMLInputFactory.newInstance();
      xif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
      xif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES,
      Boolean.TRUE);
      xif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE,
      Boolean.valueOf(namespaceAware));
      xif.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
      // xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES,
      // Boolean.FALSE);
      try {
      XMLStreamReader reader = xif.createXMLStreamReader(src);
      while(reader.hasNext()) {
      int e = reader.next();
      if (e == XMLStreamConstants.START_ELEMENT) {
      if (root == null || reader.getLocalName().equals(root)) {
      return reader;
      }
      fastForwardToEndOfElement(reader);
      }
      }
      } catch (XMLStreamException e) {
      if (e.getNestedException() != null) {
      log.warn(e.getNestedException().getLocalizedMessage());
      } else {
      log.warn(e.getLocalizedMessage());
      }
      if (log.isDebugEnabled()) {
      log.debug("getReader", e);
      }
      } catch (Exception e) {
      log.warn(e.getLocalizedMessage());
      if (log.isDebugEnabled()) {
      log.debug("getReader", e);
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Avoid using the SUN StAX implementation and use the RI instead.

            jsuttorsunw Jeff Suttor (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: