Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-896

Stream incorrectly closed in Services - triggers NPE and swallows original Exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Resolution: Fixed
    • 1.8
    • None
    • Utilities
    • None
    • Operating System: All
      Platform: PC

    Description

      Hello.

      The class org.apache.batik.util.Services incorrectly closes a stream, causing in some cases a NPE that swallows the original exception. This has personally caused quite a mess for finding an error in a custom application that triggered this.

      The culprit is this code:

      if ( br == null ){
      try

      { br.close(); }

      catch ( IOException ignored ){}
      br = null;
      }

      Where clearly the test should be if (br != null). Attaching the svn diff of the patch:

      Index: Service.java
      ===================================================================
      — Service.java (revision 755499)
      +++ Service.java (working copy)
      @@ -146,7 +146,7 @@
      } catch ( IOException ignored ){}
      r = null;
      }

      • if ( br == null ){
        + if ( br != null ){
        try { br.close(); }

        catch ( IOException ignored ){}

      Attachments

        Activity

          People

            batik-dev@xmlgraphics.apache.org Batik Developer's Mailing list
            fabrizio.giudici Fabrizio Giudici
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: