Bug 888248 - java.lang.NullPointerException: at org.mozilla.gecko.health.BrowserHealthRecorder (recordSearch). r=nalexander
authorRichard Newman <rnewman@mozilla.com>
Tue, 02 Jul 2013 12:08:08 -0700
changeset 144770 d8d375e82d13b786dcb642b4fb42276650f5acf6
parent 144769 14694cb699d24ff80213993dd58dc7df3caf52ec
child 144771 2ae11ca43e447fe73ca3d098d896ceab33c5aab3
push idunknown
push userunknown
push dateunknown
reviewersnalexander
bugs888248
milestone25.0a1
Bug 888248 - java.lang.NullPointerException: at org.mozilla.gecko.health.BrowserHealthRecorder (recordSearch). r=nalexander
mobile/android/base/health/BrowserHealthRecorder.java
--- a/mobile/android/base/health/BrowserHealthRecorder.java
+++ b/mobile/android/base/health/BrowserHealthRecorder.java
@@ -772,19 +772,27 @@ public class BrowserHealthRecorder imple
 
         if (location == null) {
             throw new IllegalArgumentException("location must be provided for search.");
         }
 
         final int day = storage.getDay();
         final int env = this.env;
         final String key = getEngineKey(engine);
+        final BrowserHealthRecorder self = this;
+
         ThreadUtils.postToBackgroundThread(new Runnable() {
             @Override
             public void run() {
+                final HealthReportDatabaseStorage storage = self.storage;
+                if (storage == null) {
+                    Log.d(LOG_TAG, "No storage: not recording search. Shutting down?");
+                    return;
+                }
+
                 Log.d(LOG_TAG, "Recording search: " + key + ", " + location +
                                " (" + day + ", " + env + ").");
                 final int searchField = storage.getField(MEASUREMENT_NAME_SEARCH_COUNTS,
                                                          MEASUREMENT_VERSION_SEARCH_COUNTS,
                                                          location)
                                                .getID();
                 storage.recordDailyDiscrete(env, day, searchField, key);
             }