Bug 1258789 - Add synchronized & non-failing try to WhitespaceAround. r=grisha
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 12 Apr 2016 18:20:51 -0700
changeset 330936 ebe249484944f34aab6da0539be018751c9a5444
parent 330935 30c0b243df2dd2af133a5258c8bce100225285dc
child 330937 f1a36e0e657e0c0f1fbd0747e0b27dbc3c717a93
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgrisha
bugs1258789
milestone48.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 1258789 - Add synchronized & non-failing try to WhitespaceAround. r=grisha MozReview-Commit-ID: EBnxF8j2eeY
mobile/android/app/checkstyle.xml
mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
mobile/android/base/java/org/mozilla/gecko/GeckoEditable.java
mobile/android/base/java/org/mozilla/gecko/Tab.java
mobile/android/base/java/org/mozilla/gecko/favicons/Favicons.java
mobile/android/base/java/org/mozilla/gecko/favicons/LoadFaviconTask.java
mobile/android/base/java/org/mozilla/gecko/favicons/cache/FaviconCache.java
mobile/android/base/java/org/mozilla/gecko/home/HomePanelsManager.java
mobile/android/base/java/org/mozilla/gecko/home/PanelInfoManager.java
mobile/android/base/java/org/mozilla/gecko/javaaddons/JavaAddonManagerV1.java
--- a/mobile/android/app/checkstyle.xml
+++ b/mobile/android/app/checkstyle.xml
@@ -50,13 +50,13 @@
         </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,
-                    LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH"/>
+                    LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY"/>
         </module>
     </module>
 
 </module>
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
@@ -1487,17 +1487,17 @@ public class GeckoAppShell
             }
         }
 
         ArrayList<String> directories = new ArrayList<String>();
         PackageManager pm = getApplicationContext().getPackageManager();
         List<ResolveInfo> plugins = pm.queryIntentServices(new Intent(PLUGIN_ACTION),
                 PackageManager.GET_SERVICES | PackageManager.GET_META_DATA);
 
-        synchronized(mPackageInfoCache) {
+        synchronized (mPackageInfoCache) {
 
             // clear the list of existing packageInfo objects
             mPackageInfoCache.clear();
 
 
             for (ResolveInfo info : plugins) {
 
                 // retrieve the plugin's service information
@@ -1614,17 +1614,17 @@ public class GeckoAppShell
     }
 
     static String getPluginPackage(String pluginLib) {
 
         if (pluginLib == null || pluginLib.length() == 0) {
             return null;
         }
 
-        synchronized(mPackageInfoCache) {
+        synchronized (mPackageInfoCache) {
             for (PackageInfo pkgInfo : mPackageInfoCache) {
                 if (pluginLib.contains(pkgInfo.packageName)) {
                     return pkgInfo.packageName;
                 }
             }
         }
 
         return null;
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoEditable.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoEditable.java
@@ -248,17 +248,17 @@ final class GeckoEditable extends JNIObj
             if (mListener == null) {
                 // We haven't initialized or we've been destroyed.
                 return;
             }
 
             if (mActions.isEmpty()) {
                 mActionsActive.acquireUninterruptibly();
                 mActions.offer(action);
-            } else synchronized(this) {
+            } else synchronized (this) {
                 // tryAcquire here in case Gecko thread has just released it
                 mActionsActive.tryAcquire();
                 mActions.offer(action);
             }
 
             switch (action.mType) {
             case Action.TYPE_EVENT:
             case Action.TYPE_SET_SPAN:
@@ -345,17 +345,17 @@ final class GeckoEditable extends JNIObj
         void poll() {
             if (DEBUG) {
                 ThreadUtils.assertOnGeckoThread();
             }
             if (mActions.poll() == null) {
                 throw new IllegalStateException("empty actions queue");
             }
 
-            synchronized(this) {
+            synchronized (this) {
                 if (mActions.isEmpty()) {
                     mActionsActive.release();
                 }
             }
         }
 
         /**
          * Return, but don't remove, the head of the queue, or null if queue is empty.
--- a/mobile/android/base/java/org/mozilla/gecko/Tab.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tab.java
@@ -758,35 +758,35 @@ public class Tab {
         mPluginViews.remove(view);
     }
 
     public View[] getPluginViews() {
         return mPluginViews.toArray(new View[mPluginViews.size()]);
     }
 
     public void addPluginLayer(Object surfaceOrView, Layer layer) {
-        synchronized(mPluginLayers) {
+        synchronized (mPluginLayers) {
             mPluginLayers.put(surfaceOrView, layer);
         }
     }
 
     public Layer getPluginLayer(Object surfaceOrView) {
-        synchronized(mPluginLayers) {
+        synchronized (mPluginLayers) {
             return mPluginLayers.get(surfaceOrView);
         }
     }
 
     public Collection<Layer> getPluginLayers() {
-        synchronized(mPluginLayers) {
+        synchronized (mPluginLayers) {
             return new ArrayList<Layer>(mPluginLayers.values());
         }
     }
 
     public Layer removePluginLayer(Object surfaceOrView) {
-        synchronized(mPluginLayers) {
+        synchronized (mPluginLayers) {
             return mPluginLayers.remove(surfaceOrView);
         }
     }
 
     public int getBackgroundColor() {
         return mBackgroundColor;
     }
 
--- a/mobile/android/base/java/org/mozilla/gecko/favicons/Favicons.java
+++ b/mobile/android/base/java/org/mozilla/gecko/favicons/Favicons.java
@@ -291,17 +291,17 @@ public class Favicons {
                 return dispatchResult(pageURL, targetURL, result, callback);
             }
         }
 
         // No joy using in-memory resources. Go to background thread and ask the database.
         final LoadFaviconTask task =
             new LoadFaviconTask(context, pageURL, targetURL, 0, callback, targetSize, true);
         final int taskId = task.getId();
-        synchronized(loadTasks) {
+        synchronized (loadTasks) {
             loadTasks.put(taskId, task);
         }
         task.execute();
 
         return taskId;
     }
 
     public static int getSizedFaviconForPageFromLocal(Context context, final String pageURL, final OnFaviconLoadedListener callback) {
@@ -364,17 +364,17 @@ public class Favicons {
         if (TextUtils.isEmpty(pageURL)) {
             dispatchResult(null, null, null, listener);
             return NOT_LOADING;
         }
 
         final LoadFaviconTask task =
             new LoadFaviconTask(context, pageURL, faviconURL, flags, listener, targetSize, false);
         final int taskId = task.getId();
-        synchronized(loadTasks) {
+        synchronized (loadTasks) {
             loadTasks.put(taskId, task);
         }
         task.execute();
 
         return taskId;
     }
 
     public static void putFaviconInMemCache(String pageUrl, Bitmap image) {
@@ -562,17 +562,17 @@ public class Favicons {
      * @param mimeType Mime type to check.
      * @return true if the given mime type is a container type, false otherwise.
      */
     public static boolean isContainerType(String mimeType) {
         return sDecodableMimeTypes.contains(mimeType);
     }
 
     public static void removeLoadTask(int taskId) {
-        synchronized(loadTasks) {
+        synchronized (loadTasks) {
             loadTasks.delete(taskId);
         }
     }
 
     /**
      * Method to wrap FaviconCache.isFailedFavicon for use by LoadFaviconTask.
      *
      * @param faviconURL Favicon URL to check for failure.
--- a/mobile/android/base/java/org/mozilla/gecko/favicons/LoadFaviconTask.java
+++ b/mobile/android/base/java/org/mozilla/gecko/favicons/LoadFaviconTask.java
@@ -376,17 +376,17 @@ public class LoadFaviconTask {
 
         if (isCancelled()) {
             return null;
         }
 
         Bitmap image;
         // Determine if there is already an ongoing task to fetch the Favicon we desire.
         // If there is, just join the queue and wait for it to finish. If not, we carry on.
-        synchronized(loadsInFlight) {
+        synchronized (loadsInFlight) {
             // Another load of the current Favicon is already underway
             LoadFaviconTask existingTask = loadsInFlight.get(faviconURL);
             if (existingTask != null && !existingTask.isCancelled()) {
                 existingTask.chainTasks(this);
                 isChaining = true;
 
                 // If we are chaining, we want to keep the first task started to do this job as the one
                 // in the hashmap so subsequent tasks will add themselves to its chaining list.
@@ -560,17 +560,17 @@ public class LoadFaviconTask {
         }
 
         Favicons.dispatchResult(pageUrl, faviconURL, scaled, listener);
     }
 
     void onCancelled() {
         Favicons.removeLoadTask(id);
 
-        synchronized(loadsInFlight) {
+        synchronized (loadsInFlight) {
             // Only remove from the hashmap if the task there is the one that's being canceled.
             // Cancellation of a task that would have chained is not interesting to the hashmap.
             final LoadFaviconTask primary = loadsInFlight.get(faviconURL);
             if (primary == this) {
                 loadsInFlight.remove(faviconURL);
                 return;
             }
             if (primary == null) {
--- a/mobile/android/base/java/org/mozilla/gecko/favicons/cache/FaviconCache.java
+++ b/mobile/android/base/java/org/mozilla/gecko/favicons/cache/FaviconCache.java
@@ -446,17 +446,17 @@ public class FaviconCache {
     /**
      * Set an existing element as the most recently used element. Intended for use from read transactions. While
      * write transactions may safely use this method, it will perform slightly worse than its unsafe counterpart below.
      *
      * @param element The element that is to become the most recently used one.
      * @return true if this element already existed in the list, false otherwise. (Useful for preventing multiple-insertion.)
      */
     private boolean setMostRecentlyUsedWithinRead(FaviconCacheElement element) {
-        synchronized(reorderingLock) {
+        synchronized (reorderingLock) {
             boolean contained = ordering.remove(element);
             ordering.offer(element);
             return contained;
         }
     }
 
     /**
      * Functionally equivalent to setMostRecentlyUsedWithinRead, but operates without taking the reordering semaphore.
--- a/mobile/android/base/java/org/mozilla/gecko/home/HomePanelsManager.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/HomePanelsManager.java
@@ -321,27 +321,27 @@ public class HomePanelsManager implement
 
         final Object panelRequestLock = new Object();
         final List<PanelInfo> latestPanelInfos = new ArrayList<PanelInfo>();
 
         final PanelInfoManager pm = new PanelInfoManager();
         pm.requestPanelsById(ids, new RequestCallback() {
             @Override
             public void onComplete(List<PanelInfo> panelInfos) {
-                synchronized(panelRequestLock) {
+                synchronized (panelRequestLock) {
                     latestPanelInfos.addAll(panelInfos);
                     Log.d(LOGTAG, "executeRefresh: fetched panel infos: " + panelInfos.size());
 
                     panelRequestLock.notifyAll();
                 }
             }
         });
 
         try {
-            synchronized(panelRequestLock) {
+            synchronized (panelRequestLock) {
                 panelRequestLock.wait(PANEL_INFO_TIMEOUT_MSEC);
 
                 Log.d(LOGTAG, "executeRefresh: done fetching panel infos");
                 refreshFromPanelInfos(editor, latestPanelInfos);
             }
         } catch (InterruptedException e) {
             Log.e(LOGTAG, "Failed to fetch panels from gecko", e);
         }
--- a/mobile/android/base/java/org/mozilla/gecko/home/PanelInfoManager.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/PanelInfoManager.java
@@ -70,17 +70,17 @@ public class PanelInfoManager implements
      *
      * @param ids list of panel ids to be fetched. A null value will fetch all
      *        available panels.
      * @param callback onComplete will be called on the UI thread.
      */
     public void requestPanelsById(Set<String> ids, RequestCallback callback) {
         final int requestId = sRequestId.getAndIncrement();
 
-        synchronized(sCallbacks) {
+        synchronized (sCallbacks) {
             // If there are no pending callbacks, register the event listener.
             if (sCallbacks.size() == 0) {
                 EventDispatcher.getInstance().registerGeckoThreadListener(this,
                     "HomePanels:Data");
             }
             sCallbacks.put(requestId, callback);
         }
 
@@ -126,17 +126,17 @@ public class PanelInfoManager implements
             for (int i = 0; i < count; i++) {
                 final PanelInfo panelInfo = getPanelInfoFromJSON(panels.getJSONObject(i));
                 panelInfos.add(panelInfo);
             }
 
             final RequestCallback callback;
             final int requestId = message.getInt("requestId");
 
-            synchronized(sCallbacks) {
+            synchronized (sCallbacks) {
                 callback = sCallbacks.get(requestId);
                 sCallbacks.delete(requestId);
 
                 // Unregister the event listener if there are no more pending callbacks.
                 if (sCallbacks.size() == 0) {
                     EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
                         "HomePanels:Data");
                 }
--- a/mobile/android/base/java/org/mozilla/gecko/javaaddons/JavaAddonManagerV1.java
+++ b/mobile/android/base/java/org/mozilla/gecko/javaaddons/JavaAddonManagerV1.java
@@ -34,17 +34,17 @@ public class JavaAddonManagerV1 implemen
 
     private static JavaAddonManagerV1 sInstance;
 
     // Protected by static synchronized.
     private Context mApplicationContext;
 
     private final org.mozilla.gecko.EventDispatcher mDispatcher;
 
-    // Protected by synchronized(this).
+    // Protected by synchronized (this).
     private final Map<String, EventDispatcherImpl> mGUIDToDispatcherMap = new HashMap<>();
 
     public static synchronized JavaAddonManagerV1 getInstance() {
         if (sInstance == null) {
             sInstance = new JavaAddonManagerV1();
         }
         return sInstance;
     }
@@ -148,17 +148,17 @@ public class JavaAddonManagerV1 implemen
      * likely hold indirect instances through its wrapping map, since the instance will probably
      * register event listeners that hold a reference to itself.  When these listeners are
      * unregistered, any link will be broken, allowing the instances to be garbage collected.
      */
     private class EventDispatcherImpl implements JavaAddonInterfaceV1.EventDispatcher {
         private final String guid;
         private final String dexFileName;
 
-        // Protected by synchronized(this).
+        // Protected by synchronized (this).
         private final Map<JavaAddonInterfaceV1.EventListener, Pair<NativeEventListener, String[]>> mListenerToWrapperMap = new IdentityHashMap<>();
 
         public EventDispatcherImpl(String guid, String dexFileName) {
             this.guid = guid;
             this.dexFileName = dexFileName;
         }
 
         protected class ListenerWrapper implements NativeEventListener {