ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1187002 - /incubator/ace/trunk/ace-ant-tasks/src/main/java/org/apache/ace/ant/deploymentpackage/DeploymentPackageTask.java
Date Thu, 20 Oct 2011 19:23:00 GMT
Author: marrs
Date: Thu Oct 20 19:22:59 2011
New Revision: 1187002

URL: http://svn.apache.org/viewvc?rev=1187002&view=rev
Log:
ACE-189 Applied the patch. Added some extra code to make sure all streams are always closed.

Modified:
    incubator/ace/trunk/ace-ant-tasks/src/main/java/org/apache/ace/ant/deploymentpackage/DeploymentPackageTask.java

Modified: incubator/ace/trunk/ace-ant-tasks/src/main/java/org/apache/ace/ant/deploymentpackage/DeploymentPackageTask.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-ant-tasks/src/main/java/org/apache/ace/ant/deploymentpackage/DeploymentPackageTask.java?rev=1187002&r1=1187001&r2=1187002&view=diff
==============================================================================
--- incubator/ace/trunk/ace-ant-tasks/src/main/java/org/apache/ace/ant/deploymentpackage/DeploymentPackageTask.java
(original)
+++ incubator/ace/trunk/ace-ant-tasks/src/main/java/org/apache/ace/ant/deploymentpackage/DeploymentPackageTask.java
Thu Oct 20 19:22:59 2011
@@ -173,19 +173,22 @@ public class DeploymentPackageTask exten
         }
 
         JarOutputStream output = null;
+        FileInputStream fis = null;
         try {
             output = new JarOutputStream(new FileOutputStream(m_destination), manifest);
             byte[] buffer = new byte[4096];
             for (String file : files) {
                 log("Writing to deployment package: " + file);
                 output.putNextEntry(new ZipEntry(file));
-                FileInputStream fis = new FileInputStream(new File(m_dir, file));
+                fis = new FileInputStream(new File(m_dir, file));
                 int bytes = fis.read(buffer);
                 while (bytes != -1) {
                     output.write(buffer, 0, bytes);
                     bytes = fis.read(buffer);
                 }
                 output.closeEntry();
+                fis.close();
+                fis = null;
             }
         }
         catch (Exception e) {
@@ -200,6 +203,14 @@ public class DeploymentPackageTask exten
                     throw new BuildException("Could not close deployment package " + m_destination
+ ".", e);
                 }
             }
+            if (fis != null) {
+                try {
+                    fis.close();
+                }
+                catch (IOException e) {
+                    throw new BuildException("Could not close file " + fis + ".", e);
+                }
+            }
         }
     }
 }



Mime
View raw message