ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/zip ZipFile.java
Date Fri, 13 May 2005 08:09:35 GMT
bodewig     2005/05/13 01:09:35

  Modified:    .        Tag: ANT_16_BRANCH WHATSNEW
               src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH
                        Untar.java
               src/main/org/apache/tools/zip Tag: ANT_16_BRANCH
                        ZipFile.java
  Log:
  merge
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.503.2.226 +3 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.503.2.225
  retrieving revision 1.503.2.226
  diff -u -r1.503.2.225 -r1.503.2.226
  --- WHATSNEW	11 May 2005 19:37:30 -0000	1.503.2.225
  +++ WHATSNEW	13 May 2005 08:09:35 -0000	1.503.2.226
  @@ -21,6 +21,9 @@
   * Granularity attribute for <sync> task was undocumented.
     Bugzilla report 34871.
   
  +* <unzip> and <untar> could leave file handles open on invalid
  +  archives.  Bugzilla report 34893.
  +
   Other changes:
   --------------
   
  
  
  
  No                   revision
  No                   revision
  1.37.2.6  +9 -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.37.2.5
  retrieving revision 1.37.2.6
  diff -u -r1.37.2.5 -r1.37.2.6
  --- Untar.java	6 Jan 2005 17:50:46 -0000	1.37.2.5
  +++ Untar.java	13 May 2005 08:09:35 -0000	1.37.2.6
  @@ -88,13 +88,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;
   
               while ((te = tis.getNextEntry()) != null) {
  @@ -113,6 +113,12 @@
                   } catch (IOException e) {
                       // ignore
                   }
  +            } else if (fis != null) {
  +                try {
  +                    fis.close();
  +                } catch (IOException e) {
  +                    // ignore
  +                }
               }
           }
       }
  
  
  
  No                   revision
  No                   revision
  1.8.2.7   +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.8.2.6
  retrieving revision 1.8.2.7
  diff -u -r1.8.2.6 -r1.8.2.7
  --- ZipFile.java	9 Mar 2005 18:56:27 -0000	1.8.2.6
  +++ ZipFile.java	13 May 2005 08:09:35 -0000	1.8.2.7
  @@ -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


Mime
View raw message