Bug 1042929 - Don't throw Errors from JSONObject parsing problems. r=mcomella, a=sledru
authorRichard Newman <rnewman@mozilla.com>
Thu, 24 Jul 2014 15:38:46 -0700
changeset 208181 b295f329dfd3
parent 208180 3808d8fbe348
child 208182 24aaa1ae41a6
push id3754
push userryanvm@gmail.com
push date2014-07-28 15:24 +0000
treeherdermozilla-beta@61b30b605194 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella, sledru
bugs1042929
milestone32.0
Bug 1042929 - Don't throw Errors from JSONObject parsing problems. r=mcomella, a=sledru
mobile/android/base/sync/ExtendedJSONObject.java
--- a/mobile/android/base/sync/ExtendedJSONObject.java
+++ b/mobile/android/base/sync/ExtendedJSONObject.java
@@ -45,30 +45,40 @@ public class ExtendedJSONObject {
    *
    * @param in <code>Reader</code> over a JSON-encoded input to parse; not
    *            necessarily a JSON object.
    * @return a regular Java <code>Object</code>.
    * @throws ParseException
    * @throws IOException
    */
   protected static Object parseRaw(Reader in) throws ParseException, IOException {
-    return getJSONParser().parse(in);
+    try {
+      return getJSONParser().parse(in);
+    } catch (Error e) {
+      // Don't be stupid, org.json.simple. Bug 1042929.
+      throw new ParseException(ParseException.ERROR_UNEXPECTED_EXCEPTION);
+    }
   }
 
   /**
    * Parse a JSON encoded string.
    * <p>
    * You should prefer the streaming interface {@link #parseRaw(Reader)}.
    *
    * @param input JSON-encoded input string to parse; not necessarily a JSON object.
    * @return a regular Java <code>Object</code>.
    * @throws ParseException
    */
   protected static Object parseRaw(String input) throws ParseException {
-    return getJSONParser().parse(input);
+    try {
+      return getJSONParser().parse(input);
+    } catch (Error e) {
+      // Don't be stupid, org.json.simple. Bug 1042929.
+      throw new ParseException(ParseException.ERROR_UNEXPECTED_EXCEPTION);
+    }
   }
 
   /**
    * Helper method to get a JSON array from a stream.
    *
    * @param in <code>Reader</code> over a JSON-encoded array to parse.
    * @throws ParseException
    * @throws IOException