geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsis...@apache.org
Subject svn commit: r410723 - /geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
Date Thu, 01 Jun 2006 03:16:47 GMT
Author: jsisson
Date: Wed May 31 20:16:46 2006
New Revision: 410723

URL: http://svn.apache.org/viewvc?rev=410723&view=rev
Log:
GERONIMO-2035 Merge rev 409513 from 1.1 branch to trunk - 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/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java?rev=410723&r1=410722&r2=410723&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
Wed May 31 20:16:46 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