geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsis...@apache.org
Subject svn commit: r409513 - /geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
Date Fri, 26 May 2006 00:01:09 GMT
Author: jsisson
Date: Thu May 25 17:01:09 2006
New Revision: 409513

URL: http://svn.apache.org/viewvc?rev=409513&view=rev
Log:
GERONIMO-2035 - fix minor problems that may occur in very rare situations.  Ensure FileOutputStream
is closed if JarOutputStream constructor throws exception.  Move call to  ConfigurationStoreUtil.ChecksumOutputStream
constructor inside try block to ensure zip entry gets closed (in finally block) if exception
is thrown during construction.

Modified:
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java?rev=409513&r1=409512&r2=409513&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
(original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
Thu May 25 17:01:09 2006
@@ -63,18 +63,22 @@
         File parent = destinationFile.getParentFile();
         if (parent != null && !parent.exists()) parent.mkdirs();
         
+        FileOutputStream fos = null;
         JarOutputStream out = null;
         try {
             byte[] buffer = new byte[4096];
 
+            fos = new FileOutputStream(destinationFile, false);
+            
             if (manifest != null) {
-                out = new JarOutputStream(new FileOutputStream(destinationFile, false), manifest);
+                out = new JarOutputStream(fos, manifest); 
 
                 // add the startup file which allows us to locate the startup directory
                 out.putNextEntry(new ZipEntry(META_INF_STARTUP_JAR));
+                // intentionally empty ZipEntry
                 out.closeEntry();
             } else {
-                out = new JarOutputStream(new FileOutputStream(destinationFile, false));
+                out = new JarOutputStream(fos);
             }
 
             // write the configurationData
@@ -104,14 +108,16 @@
             }
         } finally {
             close(out);
+            close(fos); // do this in case JarOutputStream contructor threw an exception
         }
     }
 
     public static void writeConfiguration(ConfigurationData configurationData, JarOutputStream
out) throws IOException {
         // save the persisted form in the source directory
         out.putNextEntry(new ZipEntry(META_INF_CONFIG_SER));
-        ConfigurationStoreUtil.ChecksumOutputStream sumOut = new ConfigurationStoreUtil.ChecksumOutputStream(out);
+        ConfigurationStoreUtil.ChecksumOutputStream sumOut = null;
         try {
+            sumOut = new ConfigurationStoreUtil.ChecksumOutputStream(out);
             ConfigurationUtil.writeConfigurationData(configurationData, sumOut);
         } finally {
             out.closeEntry();



Mime
View raw message