ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Jar.java
Date Mon, 03 Feb 2003 15:41:19 GMT
bodewig     2003/02/03 07:41:18

  Modified:    src/main/org/apache/tools/ant/taskdefs Jar.java
  Log:
  Close original archive after checking for old manifest in <jar> -
  otherwise the file may still be locked on Windows and friends when we
  try to rename it.
  
  Submitted by:	Antoine Levy-Lambert <levylambert at tiscali dash dsl dot de>
  
  Revision  Changes    Path
  1.61      +12 -2     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Jar.java
  
  Index: Jar.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Jar.java,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- Jar.java	22 Jan 2003 12:36:41 -0000	1.60
  +++ Jar.java	3 Feb 2003 15:41:18 -0000	1.61
  @@ -163,8 +163,9 @@
       public void setDestFile(File jarFile) {
           super.setDestFile(jarFile);
           if (jarFile.exists()) {
  +            ZipFile zf = null;
               try {
  -                ZipFile zf = new ZipFile(jarFile);
  +                zf = new ZipFile(jarFile);
   
                   // must not use getEntry as "well behaving" applications
                   // must accept the manifest in any capitalization
  @@ -174,13 +175,22 @@
                       if (ze.getName().equalsIgnoreCase("META-INF/MANIFEST.MF")) {
                           originalManifest = 
                               getManifest(new InputStreamReader(zf
  -                                                         .getInputStream(ze)));
  +                                                              .getInputStream(ze)));
                       }
                   }
               } catch (Throwable t) {
                   log("error while reading original manifest: " + t.getMessage(),
                       Project.MSG_WARN);
  +            } finally {
  +                if (zf != null) {
  +                    try {
  +                        zf.close();
  +                    } catch (IOException e) {
  +                        // XXX - log an error?  throw an exception?
  +                    }
  +                }
               }
  +            
           }
       }
   
  
  
  

Mime
View raw message