Bug 1077590 - Part 0: minor sanity fixes in FennecNativeDriver. r=gbrown
authorRichard Newman <rnewman@mozilla.com>
Sun, 11 Jan 2015 17:18:14 -0800
changeset 223530 48f0e0b28a4676b04c86b661210598d9877bf57b
parent 223529 8bda92fff8cb35c7a8a6350f728099ca134c0fe1
child 223531 3fc5da45d29e8bc823395b289c82a69000dffb1a
push id28096
push usercbook@mozilla.com
push dateTue, 13 Jan 2015 13:27:54 +0000
treeherdermozilla-central@0500f1032ea1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown
bugs1077590
milestone38.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);