public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* closing files after parsing the tags
@ 2008-08-06  7:51 Christian Thalinger
  0 siblings, 0 replies; only message in thread
From: Christian Thalinger @ 2008-08-06  7:51 UTC (permalink / raw)
  To: mauve-patches ml

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;
   }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-08-06  7:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-06  7:51 closing files after parsing the tags Christian Thalinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).