Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 582F69972 for ; Fri, 17 Feb 2012 20:53:21 +0000 (UTC) Received: (qmail 56148 invoked by uid 500); 17 Feb 2012 20:53:21 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 56082 invoked by uid 500); 17 Feb 2012 20:53:21 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 56072 invoked by uid 99); 17 Feb 2012 20:53:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Feb 2012 20:53:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Feb 2012 20:53:18 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 4D3431BDECD for ; Fri, 17 Feb 2012 20:52:57 +0000 (UTC) Date: Fri, 17 Feb 2012 20:52:57 +0000 (UTC) From: "Gary D. Gregory (Resolved) (JIRA)" To: issues@commons.apache.org Message-ID: <653685948.52031.1329511977317.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <599205169.50174.1329470519681.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Resolved] (IO-303) TeeOutputStream does not call branch.close() when main.close() throws an exception MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ 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