Bug 864339 - Part 2: Replace GeckoJarReader EmptyStackException with an empty() check. r=wesj
authorChris Peterson <cpeterson@mozilla.com>
Tue, 23 Apr 2013 16:00:44 -0700
changeset 140906 30bc2a74313c9ced172a2fd1805300cd305eb6c5
parent 140905 572236490691cde4e673991eaba8d5092b73edfa
child 140907 2d2b10ae4c061c53a54643a9f902ebfd9abc19bf
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)
reviewerswesj
bugs864339
milestone23.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 864339 - Part 2: Replace GeckoJarReader EmptyStackException with an empty() check. r=wesj
mobile/android/base/util/GeckoJarReader.java
--- a/mobile/android/base/util/GeckoJarReader.java
+++ b/mobile/android/base/util/GeckoJarReader.java
@@ -11,17 +11,16 @@ import android.graphics.Bitmap;
 import android.graphics.drawable.BitmapDrawable;
 import android.util.Log;
 
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.URL;
-import java.util.EmptyStackException;
 import java.util.Stack;
 
 /* Reads out of a multiple level deep jar file such as
  *  jar:jar:file:///data/app/org.mozilla.fennec.apk!/omni.ja!/chrome/chrome/content/branding/favicon32.png
  */
 public final class GeckoJarReader {
     private static final String LOGTAG = "GeckoJarReader";
 
@@ -94,40 +93,35 @@ 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) throws IOException {
+    private static InputStream getStream(NativeZip zip, Stack<String> jarUrls) {
         InputStream inputStream = null;
-        try {
-            // loop through children jar files until we reach the innermost one
-            while (jarUrls.peek() != null) {
-                String fileName = jarUrls.pop();
 
-                if (inputStream != null) {
-                    // intermediate NativeZips and InputStreams will be garbage collected.
-                    zip = new NativeZip(inputStream);
-                }
+        // loop through children jar files until we reach the innermost one
+        while (!jarUrls.empty()) {
+            String fileName = jarUrls.pop();
 
-                inputStream = zip.getInputStream(fileName);
-                if (inputStream == null) {
-                    Log.d(LOGTAG, "No Entry for " + fileName);
-                    return null;
-                }
+            if (inputStream != null) {
+                // intermediate NativeZips and InputStreams will be garbage collected.
+                zip = new NativeZip(inputStream);
+            }
 
-                // if there is nothing else on the stack, this will throw and break us out of the loop
-                jarUrls.peek();
+            inputStream = zip.getInputStream(fileName);
+            if (inputStream == null) {
+                Log.d(LOGTAG, "No Entry for " + fileName);
+                return null;
             }
-        } catch (EmptyStackException ex) {
-            Log.d(LOGTAG, "Jar reader reached end of stack");
         }
+
         return inputStream;
     }
 
     /* Returns a stack of strings breaking the url up into pieces. Each piece
      * is assumed to point to a jar file except for the final one. Callers should
      * pass in the url to parse, and null for the parent parameter (used for recursion)
      * For example, jar:jar:file:///data/app/org.mozilla.fennec.apk!/omni.ja!/chrome/chrome/content/branding/favicon32.png
      * will return: