Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-1079

ArrayIndexOutOfBoundsException after processing invalid XML

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Resolution: Fixed
    • 2.2.x
    • None
    • None
    • Operating System: AIX
      Platform: Other
    • 10597

    Description

      After processing XML which contains invalid Unicode characters, (e.g. 0x18),
      the next time the same stylesheet is used to process valid XML, it usually
      falls over with an ArrayIndexOutOfBounds exception.

      This is the code snippet which causes the problem:

      XslTranslator transform = null;
      try

      { transform = xslmanager.loadStyleSheetOnDemand(type.style, type.getName()); if (transform == null) log.debug("Failed to load style sheet"); }

      catch
      (TransformerConfigurationException ex)

      { log.error("XSLT Transformation problem", ex); return false; }

      try {
      log.debug("Applying
      style sheet");
      line =
      transform.applyStyleSheet(message);
      if (line == null)

      { log.debug("Failed to apply style sheet"); }


      log.debug("Output
      data:"+line);
      }
      catch (TransformerException ex)

      { log.error("Error transforming message", ex); // Failure point return false; }

      'Failure point' is where an exception is caught the first time the code is
      called, signifying an invalid Unicode character

      javax.xml.transform.TransformerException: An invalid XML character (Unicode:
      0x18) was found in the element content of the document.
      at org.apache.xalan.transformer.TransformerImpl.transform
      (TransformerImpl.java:660)
      at org.apache.xalan.transformer.TransformerImpl.transform
      (TransformerImpl.java:1118)

      This is handled correctly and the method is called again with valid XML. This
      time another exception is thrown:

      javax.xml.transform.TransformerException: -6
      at org.apache.xalan.transformer.TransformerImpl.transformNode
      (TransformerImpl.java:1212)
      at org.apache.xalan.transformer.TransformerImpl.run
      (TransformerImpl.java:2894)
      at java.lang.Thread.run(Thread.java:512)
      ---------
      java.lang.ArrayIndexOutOfBoundsException: -6
      at org.apache.xml.utils.NodeVector.popPair(NodeVector.java:307)
      at org.apache.xalan.transformer.TransformerImpl.popCurrentMatched
      (TransformerImpl.java:2372)
      at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode
      (TransformerImpl.java:2038)
      at org.apache.xalan.transformer.TransformerImpl.transformNode
      (TransformerImpl.java:1189)
      at org.apache.xalan.transformer.TransformerImpl.run
      (TransformerImpl.java:2894)
      at java.lang.Thread.run(Thread.java:512)

      However, the same XML can be processed if it is not proceeded by invalid XML.

      Occasionally the second message is processed correctly, but if it is, the Java
      application hangs and does not terminate correctly.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jaeda_goodman@bigfoot.com Jaeda Goodman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: