Bug 1077590 - Part 0: minor sanity fixes in FennecNativeDriver. r=gbrown
☠☠ backed out by 65d55b6ef0df ☠ ☠
authorRichard Newman <rnewman@mozilla.com>
Sun, 11 Jan 2015 17:18:14 -0800
changeset 249102 84aee740b55a35a9ea1c2c2b15f91702cde8a327
parent 249101 3c61d595997e4b80a1eb5e385e7b0ca3fd7d9d96
child 249103 20a66f47634616b532a8632a8ca0a9b13fb75bf8
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown
bugs1077590
milestone37.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 1077590 - Part 0: minor sanity fixes in FennecNativeDriver. r=gbrown
build/mobile/robocop/FennecNativeDriver.java
--- a/build/mobile/robocop/FennecNativeDriver.java
+++ b/build/mobile/robocop/FennecNativeDriver.java
@@ -282,21 +282,23 @@ public class FennecNativeDriver implemen
             while ((line = br.readLine()) != null) {
                 text.append(line);
                 text.append('\n');
             }
         } catch (IOException e) {
             log(LogLevel.ERROR, e);
         } finally {
             try {
-                br.close();
+                if (br != null) {
+                    br.close();
+                }
             } catch (IOException e) {
             }
         }
-        return text.toString();    
+        return text.toString();
     }
 
     /**
      *  Takes a string of "key=value" pairs split by \n and creates a hash table.
      */
     public static Map<String, String> convertTextToTable(String data)
     {
         HashMap<String, String> retVal = new HashMap<String, String>();
@@ -344,37 +346,40 @@ public class FennecNativeDriver implemen
     }
 
     public static void log(LogLevel level, Throwable t) {
         log(level, null, t);
     }
 
     public static void log(LogLevel level, String message, Throwable t) {
         if (mLogFile == null) {
-            assert(false);
+            throw new RuntimeException("No log file specified!");
         }
 
         if (level.isEnabled(mLogLevel)) {
             PrintWriter pw = null;
             try {
                 pw = new PrintWriter(new FileWriter(mLogFile, true));
                 if (message != null) {
                     pw.println(message);
                 }
                 if (t != null) {
                     t.printStackTrace(pw);
                 }
             } catch (IOException ioe) {
                 Log.e("Robocop", "exception with file writer on: " + mLogFile);
             } finally {
-                pw.close();
+                if (pw != null) {
+                    pw.close();
+                }
             }
+
             // PrintWriter doesn't throw IOE but sets an error flag instead,
             // so check for that
-            if (pw.checkError()) {
+            if (pw != null && pw.checkError()) {
                 Log.e("Robocop", "exception with file writer on: " + mLogFile);
             }
         }
 
         if (level == LogLevel.INFO) {
             Log.i("Robocop", message, t);
         } else if (level == LogLevel.DEBUG) {
             Log.d("Robocop", message, t);