Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 97530 invoked from network); 13 May 2005 08:09:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 May 2005 08:09:32 -0000 Received: (qmail 80752 invoked by uid 500); 13 May 2005 08:13:43 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 80491 invoked by uid 500); 13 May 2005 08:13:41 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 80478 invoked by uid 500); 13 May 2005 08:13:41 -0000 Received: (qmail 80467 invoked by uid 99); 13 May 2005 08:13:41 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 13 May 2005 01:13:41 -0700 Received: (qmail 97344 invoked by uid 1146); 13 May 2005 08:09:22 -0000 Date: 13 May 2005 08:09:22 -0000 Message-ID: <20050513080922.97343.qmail@minotaur.apache.org> From: bodewig@apache.org To: ant-cvs@apache.org Subject: cvs commit: ant/src/main/org/apache/tools/zip ZipFile.java X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N bodewig 2005/05/13 01:09:22 Modified: . WHATSNEW src/main/org/apache/tools/ant/taskdefs Untar.java src/main/org/apache/tools/zip ZipFile.java Log: and could leave streams open. PR 34893 Revision Changes Path 1.820 +3 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.819 retrieving revision 1.820 diff -u -r1.819 -r1.820 --- WHATSNEW 11 May 2005 19:37:13 -0000 1.819 +++ WHATSNEW 13 May 2005 08:09:22 -0000 1.820 @@ -213,6 +213,9 @@ * Granularity attribute for task was undocumented. Bugzilla report 34871. +* and could leave file handles open on invalid + archives. Bugzilla report 34893. + Other changes: -------------- 1.46 +7 -3 ant/src/main/org/apache/tools/ant/taskdefs/Untar.java Index: Untar.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Untar.java,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- Untar.java 6 Jan 2005 17:50:29 -0000 1.45 +++ Untar.java 13 May 2005 08:09:22 -0000 1.46 @@ -90,13 +90,13 @@ * @see Expand#expandFile(FileUtils, File, File) */ protected void expandFile(FileUtils fileUtils, File srcF, File dir) { + FileInputStream fis = null; TarInputStream tis = null; try { log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO); + fis = new FileInputStream(srcF); tis = new TarInputStream( - compression.decompress(srcF, - new BufferedInputStream( - new FileInputStream(srcF)))); + compression.decompress(srcF, new BufferedInputStream(fis))); TarEntry te = null; FileNameMapper mapper = getMapper(); while ((te = tis.getNextEntry()) != null) { @@ -111,6 +111,10 @@ ioe, getLocation()); } finally { FileUtils.close(tis); + if (tis == null) { + FileUtils.close(fis); + } + } } 1.19 +11 -2 ant/src/main/org/apache/tools/zip/ZipFile.java Index: ZipFile.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/zip/ZipFile.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- ZipFile.java 9 Mar 2005 00:20:39 -0000 1.18 +++ ZipFile.java 13 May 2005 08:09:22 -0000 1.19 @@ -138,8 +138,17 @@ public ZipFile(File f, String encoding) throws IOException { this.encoding = encoding; archive = new RandomAccessFile(f, "r"); - populateFromCentralDirectory(); - resolveLocalFileHeaderData(); + try { + populateFromCentralDirectory(); + resolveLocalFileHeaderData(); + } catch (IOException e) { + try { + archive.close(); + } catch (IOException e2) { + // swallow, throw the original exception instead + } + throw e; + } } /** --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org