geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsis...@apache.org
Subject svn commit: r368569 - /geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
Date Fri, 13 Jan 2006 03:16:58 GMT
Author: jsisson
Date: Thu Jan 12 19:16:50 2006
New Revision: 368569

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

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

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java?rev=368569&r1=368568&r2=368569&view=diff
==============================================================================
--- 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
Thu Jan 12 19:16:50 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...



Mime
View raw message