Bug 1300139 - Handle JSON NPE in DownloadContentCatalog; r=sebastian
authorGeoff Brown <gbrown@mozilla.com>
Tue, 06 Sep 2016 11:31:03 -0600
changeset 312898 c27d9a2bc26136de943b9a114aa326db414cf6fb
parent 312841 83c6065c6f646825990b0779b9820d2da0213bd0
child 312899 13a0934e2cc9625db2aff4a17f301e89bce4997d
push id30665
push usercbook@mozilla.com
push dateWed, 07 Sep 2016 15:20:43 +0000
treeherdermozilla-central@95acb9299faf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1300139
milestone51.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 1300139 - Handle JSON NPE in DownloadContentCatalog; r=sebastian
mobile/android/base/java/org/mozilla/gecko/dlc/catalog/DownloadContentCatalog.java
--- a/mobile/android/base/java/org/mozilla/gecko/dlc/catalog/DownloadContentCatalog.java
+++ b/mobile/android/base/java/org/mozilla/gecko/dlc/catalog/DownloadContentCatalog.java
@@ -229,16 +229,22 @@ public class DownloadContentCatalog {
         } catch (FileNotFoundException e) {
             Log.d(LOGTAG, "Catalog file does not exist: Bootstrapping initial catalog");
             loadedContent = DownloadContentBootstrap.createInitialDownloadContentList();
         } catch (JSONException e) {
             Log.w(LOGTAG, "Unable to parse catalog JSON. Re-creating catalog.", e);
             // Catalog seems to be broken. Re-create catalog:
             loadedContent = DownloadContentBootstrap.createInitialDownloadContentList();
             hasCatalogChanged = true; // Indicate that we want to persist the new catalog
+        } catch (NullPointerException e) {
+            // Bad content can produce an NPE in JSON code -- bug 1300139
+            Log.w(LOGTAG, "Unable to parse catalog JSON. Re-creating catalog.", e);
+            // Catalog seems to be broken. Re-create catalog:
+            loadedContent = DownloadContentBootstrap.createInitialDownloadContentList();
+            hasCatalogChanged = true; // Indicate that we want to persist the new catalog
         } catch (UnsupportedEncodingException e) {
             AssertionError error = new AssertionError("Should not happen: This device does not speak UTF-8");
             error.initCause(e);
             throw error;
         } catch (IOException e) {
             Log.d(LOGTAG, "Can't read catalog due to IOException", e);
         }