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

NullpointerException when handling a TransformerException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.7
    • None
    • Xalan
    • None

    Description

      When a TransfomerException is thrown, a NullpointerException occurs if its locator is null:

      Look at at line 1407 of org.apache.xalan.transformer.TransformerImpl in method 'transformNode':

      else if(se instanceof TransformerException)

      { TransformerException te = ((TransformerException)se); SAXSourceLocator sl = new SAXSourceLocator( te.getLocator() ); m_serializationHandler.fatalError(new org.xml.sax.SAXParseException(te.getMessage(), sl, te)); }

      te.getLocator() may be null, and the SAXSourceLocator constructor fails with NPE.
      It results in the fact that the foolowing line is not call and the regular SAXParseException is not raised.
      Then, the parsing fails silently.

      I suggest:

      TransformerException te = ((TransformerException)se);
      SAXSourceLocator sl = null;
      if (te.getLocator() !=null )

      { sl = new SAXSourceLocator( te.getLocator() ); }

      m_serializationHandler.fatalError(new org.xml.sax.SAXParseException(te.getMessage(), sl, te));

      (SAXParseException accepts null SAXSourceLocator in its constructor)

      Attachments

        Activity

          People

            Unassigned Unassigned
            cmarton Christophe Marton
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: