Bug 886156 - Part 2: don't initialize PIC with null add-ons. r=nalexander, a=bajaj
authorRichard Newman <rnewman@mozilla.com>
Tue, 25 Jun 2013 22:34:43 -0700
changeset 147846 01af93611916714ae5d9a1def9af0ddd462cb9ed
parent 147845 d54c097dc7f6061035caa5338c3f71cdb555ae38
child 147847 60301a200ffec6960ea78c77befaaebb6539beb6
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander, bajaj
bugs886156
milestone24.0a2
Bug 886156 - Part 2: don't initialize PIC with null add-ons. r=nalexander, a=bajaj
mobile/android/base/background/healthreport/ProfileInformationCache.java
--- a/mobile/android/base/background/healthreport/ProfileInformationCache.java
+++ b/mobile/android/base/background/healthreport/ProfileInformationCache.java
@@ -72,17 +72,17 @@ public class ProfileInformationCache imp
    */
   private boolean fromJSON(JSONObject object) throws JSONException {
     int version = object.optInt("version", 1);
     switch (version) {
     case FORMAT_VERSION:
       blocklistEnabled = object.getBoolean("blocklist");
       telemetryEnabled = object.getBoolean("telemetry");
       profileCreationTime = object.getLong("profileCreated");
-      addons = object.optJSONObject("addons");
+      addons = object.getJSONObject("addons");
       return true;
     default:
       Logger.warn(LOG_TAG, "Unable to restore from version " + version + " PIC file: expecting " + FORMAT_VERSION);
       return false;
     }
   }
 
   protected JSONObject readFromFile() throws FileNotFoundException, JSONException {
@@ -156,16 +156,17 @@ public class ProfileInformationCache imp
         return false;
       }
       initialized = true;
       needsWrite = false;
       return true;
     } catch (FileNotFoundException e) {
       return false;
     } catch (JSONException e) {
+      Logger.warn(LOG_TAG, "Malformed ProfileInformationCache. Not restoring.");
       return false;
     }
   }
 
   private void ensureInitialized() {
     if (!initialized) {
       throw new IllegalStateException("Not initialized.");
     }