You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by js...@apache.org on 2006/01/13 04:10:54 UTC

svn commit: r368566 - /geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java

Author: jsisson
Date: Thu Jan 12 19:10:28 2006
New Revision: 368566

URL: http://svn.apache.org/viewcvs?rev=368566&view=rev
Log:
GERONIMO-1465 - ensure InputStreams are closed rather than leaving it up to garbage collection / finalization.

Modified:
    geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java

Modified: geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java?rev=368566&r1=368565&r2=368566&view=diff
==============================================================================
--- geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java (original)
+++ geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java Thu Jan 12 19:10:28 2006
@@ -116,22 +116,32 @@
 
         index.clear();
         File indexfile = new File(rootDir, INDEX_NAME);
+        InputStream indexIs = null;
         try {
-            index.load(new BufferedInputStream(new FileInputStream(indexfile)));
+            indexIs = new BufferedInputStream(new FileInputStream(indexfile)); 
+            index.load(indexIs);
             for (Iterator i = index.values().iterator(); i.hasNext();) {
                 String id = (String) i.next();
                 maxId = Math.max(maxId, Integer.parseInt(id));
             }
         } catch (FileNotFoundException e) {
             maxId = 0;
+        } finally {
+            if (indexIs != null)
+                indexIs.close();
         }
 
         // See if there are old directories which we should clean up...
         File pendingDeletionFile = new File(rootDir, DELETE_NAME);
+        InputStream pendingIs = null;
         try {
-            pendingDeletionIndex.load(new BufferedInputStream(new FileInputStream(pendingDeletionFile)));
+            pendingIs = new BufferedInputStream(new FileInputStream(pendingDeletionFile));
+            pendingDeletionIndex.load(pendingIs);
         } catch (FileNotFoundException e) {
             // may not be one...
+        } finally {
+            if (pendingIs != null)
+                pendingIs.close();
         }
         
         // Create and start the reaper...