Commons IO
  1. Commons IO
  2. IO-303

TeeOutputStream does not call branch.close() when main.close() throws an exception

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.2
    • Component/s: Streams/Writers
    • Labels:

      Description

      TeeOutputStream.close() looks like this:

      TeeOutputStream.java
          /**
           * Closes both streams. 
           * @throws IOException if an I/O error occurs
           */
          @Override
          public void close() throws IOException {
              super.close();
              this.branch.close();
          }
      

      It is obvious that this.branch.close() is not executed when super.close() raises an exception. super.close() may in fact raise an IOException since ProxyOutputStream.handleIOException(IOException) is not overridden.

        Activity

        Fabian Barney created issue -
        Fabian Barney made changes -
        Field Original Value New Value
        Description TeeOutputStream.close() looks like this:
        {code:title=TeeOutputStream.java|borderStyle=solid}
            /**
             * Closes both streams.
             * @throws IOException if an I/O error occurs
             */
            @Override
            public void close() throws IOException {
                super.close();
                this.branch.close();
            }
        {code}

        It is obvious that {{this.branch.close()}} is not executed when {{super.close()}} raises an exception.
        TeeOutputStream.close() looks like this:
        {code:title=TeeOutputStream.java|borderStyle=solid}
            /**
             * Closes both streams.
             * @throws IOException if an I/O error occurs
             */
            @Override
            public void close() throws IOException {
                super.close();
                this.branch.close();
            }
        {code}

        It is obvious that {{this.branch.close()}} is not executed when {{super.close()}} raises an exception. {{super.close()}} may in fact raise an IOException since {{ProxyOutputStream.handleIOException(IOException)}} is not overridden.
        Gary Gregory made changes -
        Summary TeeOutputStream fails executing branch.close() when main.close() raised an exception TeeOutputStream does not call branch.close() when main.close() throws an exception
        Assignee Gary D. Gregory [ garydgregory ]
        Fix Version/s 2.2 [ 12318448 ]
        Gary Gregory made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Fabian Barney made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Gary Gregory
            Reporter:
            Fabian Barney
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development