[
https://issues.apache.org/jira/browse/IO-303?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gary D. Gregory resolved IO-303.
--------------------------------
Resolution: Fixed
This is the solution I implemented. For simplicity's sake, note that the
exception thrown is the last exception encountered.
{code:java}
/**
* Closes both output streams.
*
* If closing the main output stream throws an exception, attempt to close
the branch output stream.
*
* If closing the main and branch output streams both throw exceptions,
which exceptions is thrown by this method is
* currently unspecified and subject to change.
*
* @throws IOException
* if an I/O error occurs
*/
@Override
public void close() throws IOException {
try {
super.close();
} catch (IOException e) {
this.branch.close();
throw e;
}
this.branch.close();
}
{code}
> TeeOutputStream does not call branch.close() when main.close() throws an
> exception
> ----------------------------------------------------------------------------------
>
> Key: IO-303
> URL: https://issues.apache.org/jira/browse/IO-303
> Project: Commons IO
> Issue Type: Bug
> Components: Streams/Writers
> Affects Versions: 2.1
> Reporter: Fabian Barney
> Assignee: Gary D. Gregory
> Labels: close, stream
> Fix For: 2.2
>
>
> 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.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira