ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r414940 - in /ant/core/trunk: CONTRIBUTORS WHATSNEW src/main/org/apache/tools/ant/taskdefs/Manifest.java
Date Fri, 16 Jun 2006 22:03:44 GMT
Author: jkf
Date: Fri Jun 16 15:03:43 2006
New Revision: 414940

URL: http://svn.apache.org/viewvc?rev=414940&view=rev
Log:
Closing some streams in Manifest, patch kindly provided by John Sisson.

Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Manifest.java

Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=414940&r1=414939&r2=414940&view=diff
==============================================================================
Binary files - no diff available.

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=414940&r1=414939&r2=414940&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Jun 16 15:03:43 2006
@@ -94,6 +94,8 @@
 
 Fixed bugs:
 -----------
+* <manifest> now closes the inputstream explicitly. Bug report 39628
+
 * <rpm> now also correctly searches the first element of the path. Bug report 39345.
 
 * ant.bat now handles classpath set to "". Bug report 38914. 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Manifest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Manifest.java?rev=414940&r1=414939&r2=414940&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Manifest.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Manifest.java Fri Jun 16 15:03:43
2006
@@ -29,6 +29,7 @@
 import java.util.Hashtable;
 import java.util.Vector;
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.util.FileUtils;
 
 /**
  * Holds the data of a jar manifest.
@@ -698,28 +699,34 @@
      *            default manifest
      */
     public static Manifest getDefaultManifest() throws BuildException {
+        InputStream in = null;
+        InputStreamReader insr = null;
         try {
             String defManifest = "/org/apache/tools/ant/defaultManifest.mf";
-            InputStream in = Manifest.class.getResourceAsStream(defManifest);
+            in = Manifest.class.getResourceAsStream(defManifest);
             if (in == null) {
                 throw new BuildException("Could not find default manifest: "
                     + defManifest);
             }
             try {
-                Manifest defaultManifest
-                    = new Manifest(new InputStreamReader(in, "UTF-8"));
+                insr = new InputStreamReader(in, "UTF-8");
+                Manifest defaultManifest = new Manifest(insr);
                 Attribute createdBy = new Attribute("Created-By",
                     System.getProperty("java.vm.version") + " ("
                     + System.getProperty("java.vm.vendor") + ")");
                 defaultManifest.getMainSection().storeAttribute(createdBy);
                 return defaultManifest;
             } catch (UnsupportedEncodingException e) {
-                return new Manifest(new InputStreamReader(in));
+                insr = new InputStreamReader(in);
+                return new Manifest(insr);
             }
         } catch (ManifestException e) {
             throw new BuildException("Default manifest is invalid !!", e);
         } catch (IOException e) {
             throw new BuildException("Unable to read default manifest", e);
+        } finally {
+            FileUtils.close(insr);
+            FileUtils.close(in);
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message