closing files after parsing the tags

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

closing files after parsing the tags

Christian Thalinger
Hi!

I had some problems with "Too many open files" during my nightly tests
and the reason was, I forgot to close the files after parsing.  Here is
the patch.

- twisti

---

Index: Harness.java
===================================================================
RCS file: /cvs/mauve/mauve/Harness.java,v
retrieving revision 1.30
diff -u -3 -p -r1.30 Harness.java
--- Harness.java 25 Jun 2008 14:51:50 -0000 1.30
+++ Harness.java 6 Aug 2008 07:44:30 -0000
@@ -965,9 +965,10 @@ public class Harness
     String base = f.getAbsolutePath();
     base = base.substring(0, base.lastIndexOf(File.separatorChar));
 
+    BufferedReader r = null;
     try
       {
-        BufferedReader r = new BufferedReader(new FileReader(f));
+        r = new BufferedReader(new FileReader(f));
         String line = null;
         line = r.readLine();
         while (line != null)
@@ -1006,6 +1007,19 @@ public class Harness
         ioe.printStackTrace();
         return false;
       }
+    finally
+      {
+        try
+          {
+            r.close();
+          }
+        catch (IOException ioe)
+          {
+            // This shouldn't happen.
+            ioe.printStackTrace();
+            return false;
+          }
+      }
 
     return true;
   }