Return-Path: Delivered-To: apmail-commons-commits-archive@locus.apache.org Received: (qmail 1614 invoked from network); 6 Jul 2008 05:02:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Jul 2008 05:02:30 -0000 Received: (qmail 78328 invoked by uid 500); 6 Jul 2008 05:02:31 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 77922 invoked by uid 500); 6 Jul 2008 05:02:30 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 77913 invoked by uid 99); 6 Jul 2008 05:02:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Jul 2008 22:02:30 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Jul 2008 05:01:47 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7A55F2388A06; Sat, 5 Jul 2008 22:01:38 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r674258 - /commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java Date: Sun, 06 Jul 2008 05:01:38 -0000 To: commits@commons.apache.org From: bayard@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080706050138.7A55F2388A06@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bayard Date: Sat Jul 5 22:01:38 2008 New Revision: 674258 URL: http://svn.apache.org/viewvc?rev=674258&view=rev Log: Fixing the finally code which wasn't null-protecting, catching an exception in the code I'd previously 'fixed' and removing the outputStream variable as it was unused Modified: commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java Modified: commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java?rev=674258&r1=674257&r2=674258&view=diff ============================================================================== --- commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java (original) +++ commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java Sat Jul 5 22:01:38 2008 @@ -50,7 +50,6 @@ * @see org.apache.commons.compress.Compressor#compressStream(java.io.FileInputStream) */ public InputStream compress(InputStream input) throws CompressException { - FileOutputStream outputStream = null; FileOutputStream tempFileOutputStream = null; try { File temp = File.createTempFile("commons_","jkt"); @@ -58,18 +57,15 @@ compressTo(input, tempFileOutputStream); return new FileInputStream(temp); } catch (IOException e) { - throw new CompressException("An IO Exception has occured", e); + throw new CompressException("An I/O Exception has occured", e); } finally { - try { + try { if(tempFileOutputStream != null) { - tempFileOutputStream.close(); - } - if(outputStream != null) { - outputStream.close(); + tempFileOutputStream.close(); } - } catch (IOException e) { - throw new CompressException("An IO Exception occured while closing the streams", e); - } + } catch (IOException e) { + throw new CompressException("An I/O Exception occured while closing the streams", e); + } } } @@ -156,12 +152,21 @@ } catch (FileNotFoundException e) { throw new CompressException("File could not be found", e); } finally { - try { - inputStream.close(); - outputStream.close(); - } catch (IOException e1) { - throw new CompressException("An I/O Exception has occured while closing a stream", e1); - } + try { + if(inputStream != null) { + inputStream.close(); + } + } catch (IOException e) { + throw new CompressException("An I/O Exception occured while closing the streams", e); + } finally { + try { + if(outputStream != null) { + outputStream.close(); + } + } catch (IOException e) { + throw new CompressException("An I/O Exception occured while closing the streams", e); + } + } } } }