geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: rev 55143 - geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration
Date Wed, 20 Oct 2004 11:47:04 GMT
Author: gdamour
Date: Wed Oct 20 04:47:04 2004
New Revision: 55143

Modified:
   geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
Log:
Check that the index file has been successfully deleted and fail if not. If successfully deleted
and the temporary index file can not be renamed, then attempt to create a new index file from
scratch.

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
Wed Oct 20 04:47:04 2004
@@ -125,8 +125,18 @@
             index.store(os, null);
             os.close();
             fos = null;
-            indexFile.delete();
-            tmpFile.renameTo(indexFile);
+            if ( indexFile.exists() && false == indexFile.delete() ) {
+                throw new IOException("Can not delete file " + indexFile);
+            }
+            if ( false == tmpFile.renameTo(indexFile) ) {
+                fos = new FileOutputStream(indexFile);
+                os = new BufferedOutputStream(fos);
+                index.store(os, null);
+                os.close();
+                if ( false == tmpFile.delete() ) {
+                    log.warn("Can not delete temporary file " + tmpFile);
+                }
+            }
         } catch (IOException e) {
             if (fos != null) {
                 fos.close();

Mime
View raw message