Bug 849589 - Catch and log intermittent NativeZip exception. r=glandium a=lsblakk
authorChris Peterson <cpeterson@mozilla.com>
Sat, 25 May 2013 12:03:42 -0700
changeset 142745 6d0f086b6da2e9230bcef431ba3dc4728be89da7
parent 142744 08a29ed728b9aab9a50578aa90a1374da23280aa
child 142746 c56382a7d4a68a9800972c887fe3c5a344f6a938
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium, lsblakk
bugs849589
milestone23.0a2
Bug 849589 - Catch and log intermittent NativeZip exception. r=glandium a=lsblakk
mobile/android/base/util/GeckoJarReader.java
--- a/mobile/android/base/util/GeckoJarReader.java
+++ b/mobile/android/base/util/GeckoJarReader.java
@@ -35,17 +35,17 @@ public final class GeckoJarReader {
         Stack<String> jarUrls = parseUrl(url);
         InputStream inputStream = null;
         BitmapDrawable bitmap = null;
 
         NativeZip zip = null;
         try {
             // Load the initial jar file as a zip
             zip = getZipFile(jarUrls.pop());
-            inputStream = getStream(zip, jarUrls);
+            inputStream = getStream(zip, jarUrls, url);
             if (inputStream != null) {
                 bitmap = new BitmapDrawable(resources, inputStream);
             }
         } catch (IOException ex) {
             Log.e(LOGTAG, "Exception ", ex);
         } finally {
             if (inputStream != null) {
                 try {
@@ -65,17 +65,17 @@ public final class GeckoJarReader {
     public static String getText(String url) {
         Stack<String> jarUrls = parseUrl(url);
 
         NativeZip zip = null;
         BufferedReader reader = null;
         String text = null;
         try {
             zip = getZipFile(jarUrls.pop());
-            InputStream input = getStream(zip, jarUrls);
+            InputStream input = getStream(zip, jarUrls, url);
             if (input != null) {
                 reader = new BufferedReader(new InputStreamReader(input));
                 text = reader.readLine();
             }
         } catch (IOException ex) {
             Log.e(LOGTAG, "Exception ", ex);
         } finally {
             if (reader != null) {
@@ -93,26 +93,31 @@ public final class GeckoJarReader {
         return text;
     }
 
     private static NativeZip getZipFile(String url) throws IOException {
         URL fileUrl = new URL(url);
         return new NativeZip(fileUrl.getPath());
     }
 
-    private static InputStream getStream(NativeZip zip, Stack<String> jarUrls) {
+    private static InputStream getStream(NativeZip zip, Stack<String> jarUrls, String origUrl) {
         InputStream inputStream = null;
 
         // loop through children jar files until we reach the innermost one
         while (!jarUrls.empty()) {
             String fileName = jarUrls.pop();
 
             if (inputStream != null) {
                 // intermediate NativeZips and InputStreams will be garbage collected.
-                zip = new NativeZip(inputStream);
+                try {
+                    zip = new NativeZip(inputStream);
+                } catch (IllegalArgumentException e) {
+                    Log.e(LOGTAG, "!!! BUG 849589 !!! origUrl=" + origUrl, e);
+                    return null;
+                }
             }
 
             inputStream = zip.getInputStream(fileName);
             if (inputStream == null) {
                 Log.d(LOGTAG, "No Entry for " + fileName);
                 return null;
             }
         }