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

Exception thrown in ErrorListener.warning() swallowed by org.apache.xml.serializer.ToXMLStream.addAttribute()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.7
    • 2.7.1
    • None
    • None
    • Windows XP Home, Java 1.5

    Description

      To prevent the processing of erroneous XSLT stylesheets, I wanted to add a ErrorListener which throws an error even if the warning function is called. As the warning function does not allow throwing a TransformerException, it wrap it in a RuntimeException:

      static class XMLErrorListener implements ErrorListener {

      public void warning(TransformerException exception)

      { throw new RuntimeException(exception); }

      I however noticed that I got fewer errors than were logged before. I found out that the function org.apache.xml.serializer.ToXMLStream.addAttribute() contains a catch (Exception e) {} clause which swallows all exception thrown. Swallowing all exceptions is IMHO considered bad style. I see no reason why I should not be able to decide that I want to treat even warnings as errors and stop processing immediately.

      Other XSLT warnings do not swallow a thrown exception and therefore allow me to stop the processing.

      Attachments

        1. j2312.patch1.txt
          0.9 kB
          Brian Minchau

        Activity

          People

            minchau@ca.ibm.com Brian Minchau
            thmauch Thomas Mauch
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: