Bug 715312 - Robotium tests for Fennec Native do not close file input stream. r=kats
authorJoel Maher <jmaher@mozilla.com>
Tue, 10 Jan 2012 11:14:31 -0500
changeset 84105 36e7f9692e36100b5c48d1f84571f06f7136baa4
parent 84104 9bee22d394a9772e6fd7ef67f3ada5cd56eb22f7
child 84106 d6c0bf5999b021733f230bfdcdc203a1f869fb0f
push id4741
push userjmaher@mozilla.com
push dateTue, 10 Jan 2012 16:15:26 +0000
treeherdermozilla-inbound@d6c0bf5999b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs715312
milestone12.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 715312 - Robotium tests for Fennec Native do not close file input stream. r=kats
build/mobile/robocop/FennecNativeDriver.java.in
--- a/build/mobile/robocop/FennecNativeDriver.java.in
+++ b/build/mobile/robocop/FennecNativeDriver.java.in
@@ -260,29 +260,34 @@ public class FennecNativeDriver implemen
     }
 
   }
 
   //Takes a filename, loads the file, 
   //  and returns a string version of the entire file.
   public static String getFile(String filename)
   {
-    File file = new File(filename);
     StringBuilder text = new StringBuilder();
 
+    BufferedReader br = null;
     try {
-      BufferedReader br = new BufferedReader(new FileReader(file));
+      br = new BufferedReader(new FileReader(filename));
       String line;
 
       while ((line = br.readLine()) != null) {
         text.append(line);
         text.append('\n');
       }
     } catch(IOException e) {
       e.printStackTrace();
+    } finally {
+      try {
+        br.close();
+      } catch (IOException e) {
+      }
     }
     return text.toString();  
   }
 
   // Takes a string of "key=value" pairs split by \n and creates a hash table.
   public static HashMap convertTextToTable(String data)
   {
     HashMap retVal = new HashMap();