Bug 1258789 - Add literal catch & a few others that don't break for WhitespaceAround. r=grisha draft
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 12 Apr 2016 18:16:16 -0700
changeset 350241 e387c2bce427e33185c4dabdec7b169ef5133de8
parent 350240 c414f36187da86390b633357232c883668f9afe1
child 350242 c687476ab0ee6fb1054e507cb50495e55e856725
push id15281
push usermichael.l.comella@gmail.com
push dateWed, 13 Apr 2016 02:23:27 +0000
reviewersgrisha
bugs1258789
milestone48.0a1
Bug 1258789 - Add literal catch & a few others that don't break for WhitespaceAround. r=grisha MozReview-Commit-ID: 1En0xuxT4md
mobile/android/app/checkstyle.xml
mobile/android/base/java/org/mozilla/gecko/ActionBarTextSelection.java
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/ChromeCast.java
mobile/android/base/java/org/mozilla/gecko/FilePickerResultHandler.java
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
mobile/android/base/java/org/mozilla/gecko/GeckoInputConnection.java
mobile/android/base/java/org/mozilla/gecko/GeckoProfile.java
mobile/android/base/java/org/mozilla/gecko/GeckoView.java
mobile/android/base/java/org/mozilla/gecko/MediaPlayerManager.java
mobile/android/base/java/org/mozilla/gecko/NotificationHelper.java
mobile/android/base/java/org/mozilla/gecko/Tabs.java
mobile/android/base/java/org/mozilla/gecko/db/PasswordsProvider.java
mobile/android/base/java/org/mozilla/gecko/gfx/BitmapUtils.java
mobile/android/base/java/org/mozilla/gecko/preferences/MultiPrefMultiChoicePreference.java
mobile/android/base/java/org/mozilla/gecko/prompts/Prompt.java
mobile/android/base/java/org/mozilla/gecko/prompts/PromptListItem.java
mobile/android/base/java/org/mozilla/gecko/prompts/PromptService.java
mobile/android/base/java/org/mozilla/gecko/prompts/TabInput.java
mobile/android/base/java/org/mozilla/gecko/sqlite/SQLiteBridge.java
mobile/android/base/java/org/mozilla/gecko/updater/UpdateService.java
mobile/android/base/java/org/mozilla/gecko/util/FileUtils.java
mobile/android/base/java/org/mozilla/gecko/util/GeckoJarReader.java
mobile/android/base/java/org/mozilla/gecko/util/JSONUtils.java
mobile/android/base/java/org/mozilla/gecko/util/PrefUtils.java
mobile/android/base/java/org/mozilla/gecko/util/WebActivityMapper.java
mobile/android/base/java/org/mozilla/gecko/widget/DefaultDoorHanger.java
mobile/android/base/java/org/mozilla/gecko/widget/GeckoActionProvider.java
--- a/mobile/android/app/checkstyle.xml
+++ b/mobile/android/app/checkstyle.xml
@@ -49,13 +49,14 @@
             <property name="tokens" value="IMPORT,PACKAGE_DEF"/>
         </module>
         <module name="OuterTypeFilename"/> <!-- `class Lol` only in Lol.java -->
         <module name="WhitespaceAfter">
             <!-- TODO: (bug 1263059) Remove specific tokens to enable CAST check. -->
             <property name="tokens" value="COMMA, SEMI"/>
         </module>
         <module name="WhitespaceAround">
-            <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN"/>
+            <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN,
+                    LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR"/>
         </module>
     </module>
 
 </module>
--- a/mobile/android/base/java/org/mozilla/gecko/ActionBarTextSelection.java
+++ b/mobile/android/base/java/org/mozilla/gecko/ActionBarTextSelection.java
@@ -341,17 +341,17 @@ class ActionBarTextSelection extends Lay
                     BitmapUtils.getDrawable(anchorHandle.getContext(), iconString, new BitmapLoader() {
                         @Override
                         public void onBitmapFound(Drawable d) {
                             if (d != null) {
                                 menuitem.setIcon(d);
                             }
                         }
                     });
-                } catch(Exception ex) {
+                } catch (Exception ex) {
                     Log.i(LOGTAG, "Exception building menu", ex);
                 }
             }
             return true;
         }
 
         @Override
         public boolean onCreateActionMode(ActionModeCompat mode, Menu menu) {
@@ -360,17 +360,17 @@ class ActionBarTextSelection extends Lay
         }
 
         @Override
         public boolean onActionItemClicked(ActionModeCompat mode, MenuItem item) {
             try {
                 final JSONObject obj = mItems.getJSONObject(item.getItemId());
                 GeckoAppShell.notifyObservers("TextSelection:Action", obj.optString("id"));
                 return true;
-            } catch(Exception ex) {
+            } catch (Exception ex) {
                 Log.i(LOGTAG, "Exception calling action", ex);
             }
             return false;
         }
 
         // Called when the user exits the action mode
         @Override
         public void onDestroyActionMode(ActionModeCompat mode) {
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -906,17 +906,17 @@ public class BrowserApp extends GeckoApp
             StrictMode.setThreadPolicy(savedPolicy);
         }
     }
 
     private Class<?> getMediaPlayerManager() {
         if (AppConstants.MOZ_MEDIA_PLAYER) {
             try {
                 return Class.forName("org.mozilla.gecko.MediaPlayerManager");
-            } catch(Exception ex) {
+            } catch (Exception ex) {
                 // Ignore failures
                 Log.e(LOGTAG, "No native casting support", ex);
             }
         }
 
         return null;
     }
 
@@ -1169,17 +1169,17 @@ public class BrowserApp extends GeckoApp
         final Tab tab = Tabs.getInstance().getSelectedTab();
 
         final Prompt ps = new Prompt(this, new Prompt.PromptCallback() {
             @Override
             public void onPromptFinished(String result) {
                 int itemId = -1;
                 try {
                   itemId = new JSONObject(result).getInt("button");
-                } catch(JSONException ex) {
+                } catch (JSONException ex) {
                     Log.e(LOGTAG, "Exception reading bookmark prompt result", ex);
                 }
 
                 if (tab == null) {
                     return;
                 }
 
                 if (itemId == 0) {
@@ -3609,17 +3609,17 @@ public class BrowserApp extends GeckoApp
                             GeckoProfile.leaveGuestSession(BrowserApp.this);
 
                             // Now's a good time to make sure we're not displaying the Guest Browsing notification.
                             GuestSession.hideNotification(BrowserApp.this);
                         }
 
                         doRestart(args);
                     }
-                } catch(JSONException ex) {
+                } catch (JSONException ex) {
                     Log.e(LOGTAG, "Exception reading guest mode prompt result", ex);
                 }
             }
         });
 
         Resources res = getResources();
         ps.setButtons(new String[] {
             res.getString(R.string.guest_session_dialog_continue),
--- a/mobile/android/base/java/org/mozilla/gecko/ChromeCast.java
+++ b/mobile/android/base/java/org/mozilla/gecko/ChromeCast.java
@@ -299,17 +299,17 @@ class ChromeCast implements GeckoMediaPl
                     if (!status.isSuccess()) {
                         debug("Unable to play: " + status.getStatusCode());
                         sendError(callback, status.toString());
                     } else {
                         sendSuccess(callback, null);
                     }
                 }
             });
-        } catch(IllegalStateException ex) {
+        } catch (IllegalStateException ex) {
             // The media player may throw if the session has been killed. For now, we're just catching this here.
             sendError(callback, "Error playing");
         }
     }
 
     @Override
     public void pause(final EventCallback callback) {
         if (!verifySession(callback)) {
@@ -324,17 +324,17 @@ class ChromeCast implements GeckoMediaPl
                     if (!status.isSuccess()) {
                         debug("Unable to pause: " + status.getStatusCode());
                         sendError(callback, status.toString());
                     } else {
                         sendSuccess(callback, null);
                     }
                 }
             });
-        } catch(IllegalStateException ex) {
+        } catch (IllegalStateException ex) {
             // The media player may throw if the session has been killed. For now, we're just catching this here.
             sendError(callback, "Error pausing");
         }
     }
 
     @Override
     public void end(final EventCallback callback) {
         if (!verifySession(callback)) {
@@ -353,27 +353,27 @@ class ChromeCast implements GeckoMediaPl
                             apiClient.disconnect();
                             apiClient = null;
 
                             if (callback != null) {
                                 sendSuccess(callback, null);
                             }
 
                             return;
-                        } catch(Exception ex) {
+                        } catch (Exception ex) {
                             debug("Error ending", ex);
                         }
                     }
 
                     if (callback != null) {
                         sendError(callback, result.getStatus().toString());
                     }
                 }
             });
-        } catch(IllegalStateException ex) {
+        } catch (IllegalStateException ex) {
             // The media player may throw if the session has been killed. For now, we're just catching this here.
             sendError(callback, "Error stopping");
         }
     }
 
     class MirrorChannel implements MessageReceivedCallback {
         /**
          * @return custom namespace
--- a/mobile/android/base/java/org/mozilla/gecko/FilePickerResultHandler.java
+++ b/mobile/android/base/java/org/mozilla/gecko/FilePickerResultHandler.java
@@ -230,17 +230,17 @@ class FilePickerResultHandler implements
                     fos.close();
                     is.close();
                     tempFile = file.getAbsolutePath();
                     sendResult((tempFile == null) ? "" : tempFile);
 
                     if (tabId > -1 && !TextUtils.isEmpty(tempFile)) {
                         Tabs.registerOnTabsChangedListener(this);
                     }
-                } catch(IOException ex) {
+                } catch (IOException ex) {
                     Log.i(LOGTAG, "Error writing file", ex);
                 } finally {
                     if (fos != null) {
                         try {
                             fos.close();
                         } catch (IOException e) { /* not much to do here */ }
                     }
                 }
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -460,35 +460,35 @@ public abstract class GeckoApp
             final SharedPreferences prefs = GeckoSharedPrefs.forProfile(this);
             final Set<String> clearSet =
                     PrefUtils.getStringSet(prefs, ClearOnShutdownPref.PREF, new HashSet<String>());
 
             final JSONObject clearObj = new JSONObject();
             for (String clear : clearSet) {
                 try {
                     clearObj.put(clear, true);
-                } catch(JSONException ex) {
+                } catch (JSONException ex) {
                     Log.e(LOGTAG, "Error adding clear object " + clear, ex);
                 }
             }
 
             final JSONObject res = new JSONObject();
             try {
                 res.put("sanitize", clearObj);
-            } catch(JSONException ex) {
+            } catch (JSONException ex) {
                 Log.e(LOGTAG, "Error adding sanitize object", ex);
             }
 
             // If the user has opted out of session restore, and does want to clear history
             // we also want to prevent the current session info from being saved.
             if (clearObj.has("private.data.history")) {
                 final String sessionRestore = getSessionRestorePreference();
                 try {
                     res.put("dontSaveSession", "quit".equals(sessionRestore));
-                } catch(JSONException ex) {
+                } catch (JSONException ex) {
                     Log.e(LOGTAG, "Error adding session restore data", ex);
                 }
             }
 
             GeckoAppShell.notifyObservers("Browser:Quit", res.toString());
             doShutdown();
             return true;
         }
@@ -977,32 +977,32 @@ public abstract class GeckoApp
                     public void onActivityResult (int resultCode, Intent data) {
                         getContentResolver().delete(intent.getData(), null, null);
                     }
                 };
                 ActivityHandlerHelper.startIntentForActivity(this, chooser, handler);
             } else {
                 SnackbarHelper.showSnackbar(this, getString(R.string.set_image_fail), Snackbar.LENGTH_LONG);
             }
-        } catch(OutOfMemoryError ome) {
+        } catch (OutOfMemoryError ome) {
             Log.e(LOGTAG, "Out of Memory when converting to byte array", ome);
-        } catch(IOException ioe) {
+        } catch (IOException ioe) {
             Log.e(LOGTAG, "I/O Exception while setting wallpaper", ioe);
         } finally {
             if (is != null) {
                 try {
                     is.close();
-                } catch(IOException ioe) {
+                } catch (IOException ioe) {
                     Log.w(LOGTAG, "I/O Exception while closing stream", ioe);
                 }
             }
             if (os != null) {
                 try {
                     os.close();
-                } catch(IOException ioe) {
+                } catch (IOException ioe) {
                     Log.w(LOGTAG, "I/O Exception while closing stream", ioe);
                 }
             }
         }
     }
 
     private int getBitmapSampleSize(BitmapFactory.Options options, int idealWidth, int idealHeight) {
         int width = options.outWidth;
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
@@ -1819,17 +1819,17 @@ public class GeckoAppShell
                 Iterator<Integer> it = params.getSupportedPreviewFrameRates().iterator();
                 while (it.hasNext()) {
                     int nFps = it.next();
                     if (Math.abs(nFps - kPreferredFPS) < fpsDelta) {
                         fpsDelta = Math.abs(nFps - kPreferredFPS);
                         params.setPreviewFrameRate(nFps);
                     }
                 }
-            } catch(Exception e) {
+            } catch (Exception e) {
                 params.setPreviewFrameRate(kPreferredFPS);
             }
 
             // set up the closest preview size available
             Iterator<android.hardware.Camera.Size> sit = params.getSupportedPreviewSizes().iterator();
             int sizeDelta = 10000000;
             int bufferSize = 0;
             while (sit.hasNext()) {
@@ -1866,17 +1866,17 @@ public class GeckoAppShell
                 }
             });
             sCamera.startPreview();
             params = sCamera.getParameters();
             result[0] = 1;
             result[1] = params.getPreviewSize().width;
             result[2] = params.getPreviewSize().height;
             result[3] = params.getPreviewFrameRate();
-        } catch(RuntimeException e) {
+        } catch (RuntimeException e) {
             Log.w(LOGTAG, "initCamera RuntimeException.", e);
             result[0] = result[1] = result[2] = result[3] = 0;
         }
         return result;
     }
 
     @WrapForJNI
     static synchronized void closeCamera() {
@@ -2237,26 +2237,26 @@ public class GeckoAppShell
                         return null;
                     }
                     final String pkg = splits[1];
                     final PackageManager pm = getApplicationContext().getPackageManager();
                     final Drawable d = pm.getApplicationIcon(pkg);
                     final Bitmap bitmap = BitmapUtils.getBitmapFromDrawable(d);
                     return new BitmapConnection(bitmap);
                 }
-            } catch(Exception ex) {
+            } catch (Exception ex) {
                 Log.e(LOGTAG, "error", ex);
             }
 
             // if the colon got stripped, put it back
             int colon = spec.indexOf(':');
             if (colon == -1 || colon > spec.indexOf('/')) {
                 spec = spec.replaceFirst("/", ":/");
             }
-        } catch(Exception ex) {
+        } catch (Exception ex) {
             return null;
         }
         return null;
     }
 
     @WrapForJNI(allowMultithread = true, narrowChars = true)
     static String connectionGetMimeType(URLConnection connection) {
         return connection.getContentType();
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoInputConnection.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoInputConnection.java
@@ -285,17 +285,17 @@ class GeckoInputConnection
             // Fake a selection change, because the IME clears the composition when
             // the selection changes, even if soft-resetting. Offsets here must be
             // different from the previous selection offsets, and -1 seems to be a
             // reasonable, deterministic value
             notifySelectionChange(-1, -1);
         }
         try {
             imm.restartInput(v);
-        } catch(RuntimeException e) {
+        } catch (RuntimeException e) {
             Log.e(LOGTAG, "Error restarting input", e);
         }
     }
 
     private void resetInputConnection() {
         if (mBatchEditCount != 0) {
             Log.w(LOGTAG, "resetting with mBatchEditCount = " + mBatchEditCount);
             mBatchEditCount = 0;
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoProfile.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoProfile.java
@@ -490,17 +490,17 @@ public final class GeckoProfile {
             final File lockFile = new File(getDir(), LOCK_FILE_NAME);
             final boolean result = lockFile.createNewFile();
             if (lockFile.exists()) {
                 mLocked = LockState.LOCKED;
             } else {
                 mLocked = LockState.UNLOCKED;
             }
             return result;
-        } catch(IOException ex) {
+        } catch (IOException ex) {
             Log.e(LOGTAG, "Error locking profile", ex);
         }
         mLocked = LockState.UNLOCKED;
         return false;
     }
 
     public boolean unlock() {
         final File profileDir;
@@ -522,17 +522,17 @@ public final class GeckoProfile {
 
             final boolean result = delete(lockFile);
             if (result) {
                 mLocked = LockState.UNLOCKED;
             } else {
                 mLocked = LockState.LOCKED;
             }
             return result;
-        } catch(IOException ex) {
+        } catch (IOException ex) {
             Log.e(LOGTAG, "Error unlocking profile", ex);
         }
 
         mLocked = LockState.LOCKED;
         return false;
     }
 
     @RobocopTarget
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoView.java
@@ -538,17 +538,17 @@ public class GeckoView extends LayerView
         public PromptResult(JSONObject message) {
             mMessage = message;
         }
 
         private JSONObject makeResult(int resultCode) {
             JSONObject result = new JSONObject();
             try {
                 result.put("button", resultCode);
-            } catch(JSONException ex) { }
+            } catch (JSONException ex) { }
             return result;
         }
 
         /**
         * Handle a confirmation response from the user.
         */
         public void confirm() {
             JSONObject result = makeResult(RESULT_OK);
@@ -558,17 +558,17 @@ public class GeckoView extends LayerView
         /**
         * Handle a confirmation response from the user.
         * @param value String value to return to the browser context.
         */
         public void confirmWithValue(String value) {
             JSONObject result = makeResult(RESULT_OK);
             try {
                 result.put("textbox0", value);
-            } catch(JSONException ex) { }
+            } catch (JSONException ex) { }
             EventDispatcher.sendResponse(mMessage, result);
         }
 
         /**
         * Handle a cancellation response from the user.
         */
         public void cancel() {
             JSONObject result = makeResult(RESULT_CANCEL);
--- a/mobile/android/base/java/org/mozilla/gecko/MediaPlayerManager.java
+++ b/mobile/android/base/java/org/mozilla/gecko/MediaPlayerManager.java
@@ -193,17 +193,17 @@ public class MediaPlayerManager extends 
             }
         };
 
     private GeckoMediaPlayer getMediaPlayerForRoute(MediaRouter.RouteInfo route) {
         try {
             if (route.supportsControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)) {
                 return new ChromeCast(getActivity(), route);
             }
-        } catch(Exception ex) {
+        } catch (Exception ex) {
             debug("Error handling presentation", ex);
         }
 
         return null;
     }
 
     @Override
     public void onPause() {
--- a/mobile/android/base/java/org/mozilla/gecko/NotificationHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/NotificationHelper.java
@@ -356,17 +356,17 @@ public final class NotificationHelper im
         for (Iterator<String> i = mClearableNotifications.keySet().iterator(); i.hasNext();) {
             final String id = i.next();
             final String json = mClearableNotifications.get(id);
             i.remove();
 
             JSONObject obj;
             try {
                 obj = new JSONObject(json);
-            } catch(JSONException ex) {
+            } catch (JSONException ex) {
                 obj = new JSONObject();
             }
 
             closeNotification(id, obj.optString(HANDLER_ATTR), obj.optString(COOKIE_ATTR));
         }
     }
 
     public static void destroy() {
--- a/mobile/android/base/java/org/mozilla/gecko/Tabs.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tabs.java
@@ -86,17 +86,17 @@ public class Tabs implements GeckoEventL
             this.db = GeckoProfile.get(context).getDB();
             this.tabs = tabsInOrder;
         }
 
         @Override
         public void run() {
             try {
                 db.getTabsAccessor().persistLocalTabs(context.getContentResolver(), tabs);
-            } catch(SQLiteException e) {
+            } catch (SQLiteException e) {
                 Log.w(LOGTAG, "Error persisting local tabs", e);
             }
         }
     };
 
     private Tabs() {
         EventDispatcher.getInstance().registerGeckoThreadListener(this,
             "Tab:Added",
--- a/mobile/android/base/java/org/mozilla/gecko/db/PasswordsProvider.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/PasswordsProvider.java
@@ -319,20 +319,20 @@ public class PasswordsProvider extends S
     @Override
     public void onPostQuery(Cursor cursor, Uri uri, SQLiteBridge db) {
         int passwordIndex = -1;
         int usernameIndex = -1;
         String profilePath = null;
 
         try {
             passwordIndex = cursor.getColumnIndexOrThrow(Passwords.ENCRYPTED_PASSWORD);
-        } catch(Exception ex) { }
+        } catch (Exception ex) { }
         try {
             usernameIndex = cursor.getColumnIndexOrThrow(Passwords.ENCRYPTED_USERNAME);
-        } catch(Exception ex) { }
+        } catch (Exception ex) { }
 
         if (passwordIndex > -1 || usernameIndex > -1) {
             MatrixBlobCursor m = (MatrixBlobCursor)cursor;
             if (cursor.moveToFirst()) {
                 do {
                     if (passwordIndex > -1) {
                         String decrypted = doCrypto(cursor.getString(passwordIndex), uri, false);;
                         m.set(passwordIndex, decrypted);
--- a/mobile/android/base/java/org/mozilla/gecko/gfx/BitmapUtils.java
+++ b/mobile/android/base/java/org/mozilla/gecko/gfx/BitmapUtils.java
@@ -219,44 +219,44 @@ public final class BitmapUtils {
         return decodeUrl(uri.toString());
     }
 
     public static Bitmap decodeUrl(String urlString) {
         URL url;
 
         try {
             url = new URL(urlString);
-        } catch(MalformedURLException e) {
+        } catch (MalformedURLException e) {
             Log.w(LOGTAG, "decodeUrl: malformed URL " + urlString);
             return null;
         }
 
         return decodeUrl(url);
     }
 
     public static Bitmap decodeUrl(URL url) {
         InputStream stream = null;
 
         try {
             stream = url.openStream();
-        } catch(IOException e) {
+        } catch (IOException e) {
             Log.w(LOGTAG, "decodeUrl: IOException downloading " + url);
             return null;
         }
 
         if (stream == null) {
             Log.w(LOGTAG, "decodeUrl: stream not found downloading " + url);
             return null;
         }
 
         Bitmap bitmap = decodeStream(stream);
 
         try {
             stream.close();
-        } catch(IOException e) {
+        } catch (IOException e) {
             Log.w(LOGTAG, "decodeUrl: IOException closing stream " + url, e);
         }
 
         return bitmap;
     }
 
     public static Bitmap decodeResource(Context context, int id) {
         return decodeResource(context, id, null);
@@ -401,34 +401,34 @@ public final class BitmapUtils {
 
         final String scheme = resourceUrl.getScheme();
         if ("drawable".equals(scheme)) {
             String resource = resourceUrl.getSchemeSpecificPart();
             resource = resource.substring(resource.lastIndexOf('/') + 1);
 
             try {
                 return Integer.parseInt(resource);
-            } catch(NumberFormatException ex) {
+            } catch (NumberFormatException ex) {
                 // This isn't a resource id, try looking for a string
             }
 
             try {
                 final Class<R.drawable> drawableClass = R.drawable.class;
                 final Field f = drawableClass.getField(resource);
                 icon = f.getInt(null);
             } catch (final NoSuchFieldException e1) {
 
                 // just means the resource doesn't exist for fennec. Check in Android resources
                 try {
                     final Class<android.R.drawable> drawableClass = android.R.drawable.class;
                     final Field f = drawableClass.getField(resource);
                     icon = f.getInt(null);
                 } catch (final NoSuchFieldException e2) {
                     // This drawable doesn't seem to exist...
-                } catch(Exception e3) {
+                } catch (Exception e3) {
                     Log.i(LOGTAG, "Exception getting drawable", e3);
                 }
 
             } catch (Exception e4) {
               Log.i(LOGTAG, "Exception getting drawable", e4);
             }
 
             resourceUrl = null;
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/MultiPrefMultiChoicePreference.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/MultiPrefMultiChoicePreference.java
@@ -87,17 +87,17 @@ class MultiPrefMultiChoicePreference ext
                         // Save the pref and remove the old preference.
                         setValue(i, val);
                         edit.remove(key);
                     }
 
                     persist(edit);
                     edit.putBoolean(getKey() + IMPORT_SUFFIX, true);
                     edit.apply();
-                } catch(Exception ex) {
+                } catch (Exception ex) {
                     Log.i(LOGTAG, "Err", ex);
                 }
             }
         });
     }
 
 
     @Override
--- a/mobile/android/base/java/org/mozilla/gecko/prompts/Prompt.java
+++ b/mobile/android/base/java/org/mozilla/gecko/prompts/Prompt.java
@@ -85,17 +85,17 @@ public class Prompt implements OnClickLi
         mButtons = getStringArray(message, "buttons");
 
         JSONArray inputs = getSafeArray(message, "inputs");
         mInputs = new PromptInput[inputs.length()];
         for (int i = 0; i < mInputs.length; i++) {
             try {
                 mInputs[i] = PromptInput.getInput(inputs.getJSONObject(i));
                 mInputs[i].setListener(this);
-            } catch(Exception ex) { }
+            } catch (Exception ex) { }
         }
 
         PromptListItem[] menuitems = PromptListItem.getArray(message.optJSONArray("listitems"));
         String selected = message.optString("choiceMode");
 
         int choiceMode = ListView.CHOICE_MODE_NONE;
         if ("single".equals(selected)) {
             choiceMode = ListView.CHOICE_MODE_SINGLE;
@@ -110,17 +110,17 @@ public class Prompt implements OnClickLi
         show(title, text, menuitems, choiceMode);
     }
 
      public void show(String title, String text, PromptListItem[] listItems, int choiceMode) {
         ThreadUtils.assertOnUiThread();
 
         try {
             create(title, text, listItems, choiceMode);
-        } catch(IllegalStateException ex) {
+        } catch (IllegalStateException ex) {
             Log.i(LOGTAG, "Error building dialog", ex);
             return;
         }
 
         if (mTabId != Tabs.INVALID_TAB_ID) {
             Tabs.registerOnTabsChangedListener(this);
 
             final Tab tab = Tabs.getInstance().getTab(mTabId);
@@ -227,48 +227,48 @@ public class Prompt implements OnClickLi
                 if (!selectedItems.contains(which)) {
                     selected.put(which);
                 }
 
                 result.put("button", which);
             }
 
             result.put("list", selected);
-        } catch(JSONException ex) { }
+        } catch (JSONException ex) { }
     }
 
     /* Adds to a result value from the inputs that can be shown in dialogs.
      * Each input will set its own value in the result.
      */
     private void addInputValues(final JSONObject result) {
         try {
             if (mInputs != null) {
                 for (int i = 0; i < mInputs.length; i++) {
                     if (mInputs[i] != null) {
                         result.put(mInputs[i].getId(), mInputs[i].getValue());
                     }
                 }
             }
-        } catch(JSONException ex) { }
+        } catch (JSONException ex) { }
     }
 
     /* Adds the selected button to a result. This should only be called if there
      * are no lists shown on the dialog, since they also write their results to the button
      * attribute.
      */
     private void addButtonResult(final JSONObject result, int which) {
         int button = -1;
         switch(which) {
             case DialogInterface.BUTTON_POSITIVE : button = 0; break;
             case DialogInterface.BUTTON_NEUTRAL  : button = 1; break;
             case DialogInterface.BUTTON_NEGATIVE : button = 2; break;
         }
         try {
             result.put("button", button);
-        } catch(JSONException ex) { }
+        } catch (JSONException ex) { }
     }
 
     @Override
     public void onClick(DialogInterface dialog, int which) {
         ThreadUtils.assertOnUiThread();
         closeDialog(which);
     }
 
@@ -403,17 +403,17 @@ public class Prompt implements OnClickLi
                 // If we're showing some sort of scrollable list, force an inverse background.
                 builder.setInverseBackgroundForced(true);
                 builder.setView(root);
             } else {
                 ScrollView view = new ScrollView(mContext);
                 view.addView(root);
                 builder.setView(view);
             }
-        } catch(Exception ex) {
+        } catch (Exception ex) {
             Log.e(LOGTAG, "Error showing prompt inputs", ex);
             // We cannot display these input widgets with this sdk version,
             // do not display any dialog and finish the prompt now.
             cancelDialog();
             return false;
         }
 
         return true;
@@ -457,17 +457,17 @@ public class Prompt implements OnClickLi
 
     /* Called in situations where we want to cancel the dialog . This can happen if the user hits back,
      *  or if the dialog can't be created because of invalid JSON.
      */
     private void cancelDialog() {
         JSONObject ret = new JSONObject();
         try {
             ret.put("button", -1);
-        } catch(Exception ex) { }
+        } catch (Exception ex) { }
         addInputValues(ret);
         notifyClosing(ret);
     }
 
     /* Called any time we're closing the dialog to cleanup and notify listeners that the dialog
      * is closing.
      */
     private void closeDialog(int which) {
@@ -482,17 +482,17 @@ public class Prompt implements OnClickLi
     }
 
     /* Called any time we're closing the dialog to cleanup and notify listeners that the dialog
      * is closing.
      */
     private void notifyClosing(JSONObject aReturn) {
         try {
             aReturn.put("guid", mGuid);
-        } catch(JSONException ex) { }
+        } catch (JSONException ex) { }
 
         if (mTabId != Tabs.INVALID_TAB_ID) {
             Tabs.unregisterOnTabsChangedListener(this);
         }
 
         // poke the Gecko thread in case it's waiting for new events
         GeckoAppShell.sendEventToGecko(GeckoEvent.createNoOpEvent());
 
@@ -520,32 +520,32 @@ public class Prompt implements OnClickLi
 
     public static String[] getStringArray(JSONObject aObject, String aName) {
         JSONArray items = getSafeArray(aObject, aName);
         int length = items.length();
         String[] list = new String[length];
         for (int i = 0; i < length; i++) {
             try {
                 list[i] = items.getString(i);
-            } catch(Exception ex) { }
+            } catch (Exception ex) { }
         }
         return list;
     }
 
     private static boolean[] getBooleanArray(JSONObject aObject, String aName) {
         JSONArray items = new JSONArray();
         try {
             items = aObject.getJSONArray(aName);
-        } catch(Exception ex) { return null; }
+        } catch (Exception ex) { return null; }
         int length = items.length();
         boolean[] list = new boolean[length];
         for (int i = 0; i < length; i++) {
             try {
                 list[i] = items.getBoolean(i);
-            } catch(Exception ex) { }
+            } catch (Exception ex) { }
         }
         return list;
     }
 
     public interface PromptCallback {
 
         /**
          * Called when the Prompt has been completed (i.e. when the user has selected an item or action in the Prompt).
--- a/mobile/android/base/java/org/mozilla/gecko/prompts/PromptListItem.java
+++ b/mobile/android/base/java/org/mozilla/gecko/prompts/PromptListItem.java
@@ -106,14 +106,14 @@ public class PromptListItem {
         }
 
         int length = items.length();
         List<PromptListItem> list = new ArrayList<>(length);
         for (int i = 0; i < length; i++) {
             try {
                 PromptListItem item = new PromptListItem(items.getJSONObject(i));
                 list.add(item);
-            } catch(Exception ex) { }
+            } catch (Exception ex) { }
         }
 
         return list.toArray(new PromptListItem[length]);
     }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/prompts/PromptService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/prompts/PromptService.java
@@ -54,17 +54,17 @@ public class PromptService implements Ge
             @Override
             public void run() {
                 Prompt p;
                 p = new Prompt(mContext, new Prompt.PromptCallback() {
                     @Override
                     public void onPromptFinished(String jsonResult) {
                         try {
                             EventDispatcher.sendResponse(message, new JSONObject(jsonResult));
-                        } catch(JSONException ex) {
+                        } catch (JSONException ex) {
                             Log.i(LOGTAG, "Error building json response", ex);
                         }
                     }
                 });
                 p.show(message);
             }
         });
     }
--- a/mobile/android/base/java/org/mozilla/gecko/prompts/TabInput.java
+++ b/mobile/android/base/java/org/mozilla/gecko/prompts/TabInput.java
@@ -39,17 +39,17 @@ public class TabInput extends PromptInpu
         try {
             JSONArray tabs = obj.getJSONArray("items");
             for (int i = 0; i < tabs.length(); i++) {
                 JSONObject tab = tabs.getJSONObject(i);
                 String title = tab.getString("label");
                 JSONArray items = tab.getJSONArray("items");
                 mTabs.put(title, PromptListItem.getArray(items));
             }
-        } catch(JSONException ex) {
+        } catch (JSONException ex) {
             Log.e(LOGTAG, "Exception", ex);
         }
     }
 
     @Override
     public View getView(final Context context) throws UnsupportedOperationException {
         final LayoutInflater inflater = LayoutInflater.from(context);
         mHost = (TabHost) inflater.inflate(R.layout.tab_prompt_input, null);
@@ -77,17 +77,17 @@ public class TabInput extends PromptInpu
     }
 
     @Override
     public Object getValue() {
         JSONObject obj = new JSONObject();
         try {
             obj.put("tab", mHost.getCurrentTab());
             obj.put("item", mPosition);
-        } catch(JSONException ex) { }
+        } catch (JSONException ex) { }
 
         return obj;
     }
 
     @Override
     public boolean getScrollable() {
         return true;
     }
--- a/mobile/android/base/java/org/mozilla/gecko/sqlite/SQLiteBridge.java
+++ b/mobile/android/base/java/org/mozilla/gecko/sqlite/SQLiteBridge.java
@@ -308,17 +308,17 @@ public class SQLiteBridge {
             return;
 
         try {
           if (mTransactionSuccess) {
               execSQL("COMMIT TRANSACTION");
           } else {
               execSQL("ROLLBACK TRANSACTION");
           }
-        } catch(SQLiteBridgeException ex) {
+        } catch (SQLiteBridgeException ex) {
             Log.e(LOGTAG, "Error ending transaction", ex);
         }
         mInTransaction = false;
         mTransactionSuccess = false;
     }
 
     public void setTransactionSuccessful() throws SQLiteBridgeException {
         if (!inTransaction()) {
--- a/mobile/android/base/java/org/mozilla/gecko/updater/UpdateService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/updater/UpdateService.java
@@ -641,17 +641,17 @@ public class UpdateService extends Inten
             }
         } catch (java.io.IOException e) {
             Log.e(LOGTAG, "Failed to verify update package: ", e);
             return false;
         } finally {
             try {
                 if (input != null)
                     input.close();
-            } catch(java.io.IOException e) {}
+            } catch (java.io.IOException e) {}
         }
 
         String hex = Hex.encodeHexString(digest.digest());
         if (!hex.equals(getLastHashValue())) {
             Log.e(LOGTAG, "Package hash does not match");
             return false;
         }
 
--- a/mobile/android/base/java/org/mozilla/gecko/util/FileUtils.java
+++ b/mobile/android/base/java/org/mozilla/gecko/util/FileUtils.java
@@ -68,17 +68,17 @@ public class FileUtils {
     public static boolean delete(File file, boolean recurse) {
         if (file.isDirectory() && recurse) {
             // If the quick delete failed and this is a dir, recursively delete the contents of the dir
             String files[] = file.list();
             for (String temp : files) {
                 File fileDelete = new File(file, temp);
                 try {
                     delete(fileDelete);
-                } catch(IOException ex) {
+                } catch (IOException ex) {
                     Log.i(LOGTAG, "Error deleting " + fileDelete.getPath(), ex);
                 }
             }
         }
 
         // Even if this is a dir, it should now be empty and delete should work
         return file.delete();
     }
--- a/mobile/android/base/java/org/mozilla/gecko/util/GeckoJarReader.java
+++ b/mobile/android/base/java/org/mozilla/gecko/util/GeckoJarReader.java
@@ -57,17 +57,17 @@ public final class GeckoJarReader {
                 bitmap.setTargetDensity(resources.getDisplayMetrics());
             }
         } catch (IOException | URISyntaxException ex) {
             Log.e(LOGTAG, "Exception ", ex);
         } finally {
             if (inputStream != null) {
                 try {
                     inputStream.close();
-                } catch(IOException ex) {
+                } catch (IOException ex) {
                     Log.e(LOGTAG, "Error closing stream", ex);
                 }
             }
             if (zip != null) {
                 zip.close();
             }
         }
 
@@ -88,17 +88,17 @@ public final class GeckoJarReader {
                 text = reader.readLine();
             }
         } catch (IOException | URISyntaxException ex) {
             Log.e(LOGTAG, "Exception ", ex);
         } finally {
             if (reader != null) {
                 try {
                     reader.close();
-                } catch(IOException ex) {
+                } catch (IOException ex) {
                     Log.e(LOGTAG, "Error closing reader", ex);
                 }
             }
             if (zip != null) {
                 zip.close();
             }
         }
 
--- a/mobile/android/base/java/org/mozilla/gecko/util/JSONUtils.java
+++ b/mobile/android/base/java/org/mozilla/gecko/util/JSONUtils.java
@@ -53,17 +53,17 @@ public final class JSONUtils {
 
     // Handles conversions between a JSONArray and a Set<String>
     public static Set<String> parseStringSet(JSONArray json) {
         final Set<String> ret = new HashSet<String>();
 
         for (int i = 0; i < json.length(); i++) {
             try {
                 ret.add(json.getString(i));
-            } catch(JSONException ex) {
+            } catch (JSONException ex) {
                 Log.i(LOGTAG, "Error parsing json", ex);
             }
         }
 
         return ret;
     }
 
 }
--- a/mobile/android/base/java/org/mozilla/gecko/util/PrefUtils.java
+++ b/mobile/android/base/java/org/mozilla/gecko/util/PrefUtils.java
@@ -25,30 +25,30 @@ public class PrefUtils {
                                            final Set<String> defaultVal) {
         if (!prefs.contains(key)) {
             return defaultVal;
         }
 
         // If this is Android version >= 11, try to use a Set<String>.
         try {
             return prefs.getStringSet(key, new HashSet<String>());
-        } catch(ClassCastException ex) {
+        } catch (ClassCastException ex) {
             // A ClassCastException means we've upgraded from a pre-v11 Android to a new one
             final Set<String> val = getFromJSON(prefs, key);
             SharedPreferences.Editor edit = prefs.edit();
             putStringSet(edit, key, val).apply();
             return val;
         }
     }
 
     private static Set<String> getFromJSON(SharedPreferences prefs, String key) {
         try {
             final String val = prefs.getString(key, "[]");
             return JSONUtils.parseStringSet(new JSONArray(val));
-        } catch(JSONException ex) {
+        } catch (JSONException ex) {
             Log.i(LOGTAG, "Unable to parse JSON", ex);
         }
 
         return new HashSet<String>();
     }
 
     /**
      * Cross version compatible way to save a set of strings.
--- a/mobile/android/base/java/org/mozilla/gecko/util/WebActivityMapper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/util/WebActivityMapper.java
@@ -208,14 +208,14 @@ public final class WebActivityMapper {
 
             try {
                 File dest = File.createTempFile(
                     "capture", /* prefix */
                     ext,       /* suffix */
                     destDir    /* directory */
                 );
                 intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(dest));
-            } catch(Exception e) {
+            } catch (Exception e) {
                 Log.w(LOGTAG, "Failed to add extra for " + action + " : " + e);
             }
         }
     }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/widget/DefaultDoorHanger.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/DefaultDoorHanger.java
@@ -111,17 +111,17 @@ public class DefaultDoorHanger extends D
                     PromptInput input = PromptInput.getInput(inputs.getJSONObject(i));
                     mInputs.add(input);
 
                     final int padding = mResources.getDimensionPixelSize(R.dimen.doorhanger_section_padding_medium);
                     View v = input.getView(getContext());
                     styleInput(input, v);
                     v.setPadding(0, 0, 0, padding);
                     group.addView(v);
-                } catch(JSONException ex) { }
+                } catch (JSONException ex) { }
             }
         }
 
         final String checkBoxText = options.optString("checkbox");
         if (!TextUtils.isEmpty(checkBoxText)) {
             mCheckBox = (CheckBox) findViewById(R.id.doorhanger_checkbox);
             mCheckBox.setText(checkBoxText);
             mCheckBox.setVisibility(VISIBLE);
--- a/mobile/android/base/java/org/mozilla/gecko/widget/GeckoActionProvider.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/GeckoActionProvider.java
@@ -351,15 +351,15 @@ public class GeckoActionProvider {
                     }
 
                     // Only alter the intent when we're sure everything has worked
                     intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(imageFile));
                 } finally {
                     IOUtils.safeStreamClose(is);
                 }
             }
-        } catch(IOException ex) {
+        } catch (IOException ex) {
             // If something went wrong, we'll just leave the intent un-changed
         } finally {
             IOUtils.safeStreamClose(os);
         }
     }
 }