cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject android commit: CB-8031 Fix race condition that shows as ConcurrentModificationException
Date Tue, 18 Nov 2014 06:20:25 GMT
Repository: cordova-android
Updated Branches:
  refs/heads/master ac284fd39 -> 1feaa7fed


CB-8031 Fix race condition that shows as ConcurrentModificationException


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/1feaa7fe
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/1feaa7fe
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/1feaa7fe

Branch: refs/heads/master
Commit: 1feaa7fed717d1f6e02508a280190c3d6914f95c
Parents: ac284fd
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Mon Nov 17 22:11:21 2014 -0800
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Mon Nov 17 22:11:21 2014 -0800

----------------------------------------------------------------------
 .../src/org/apache/cordova/PluginManager.java   | 40 ++++++++++++++------
 1 file changed, 29 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/1feaa7fe/framework/src/org/apache/cordova/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/PluginManager.java b/framework/src/org/apache/cordova/PluginManager.java
index 9ae5ce6..7ddf300 100755
--- a/framework/src/org/apache/cordova/PluginManager.java
+++ b/framework/src/org/apache/cordova/PluginManager.java
@@ -110,8 +110,12 @@ public class PluginManager {
     @Deprecated // Should not be exposed as public.
     public void startupPlugins() {
         for (PluginEntry entry : entryMap.values()) {
+            // Add a null entry to for each non-startup plugin to avoid ConcurrentModificationException
+            // When iterating plugins.
             if (entry.onload) {
                 getPlugin(entry.service);
+            } else {
+                pluginMap.put(entry.service, null);
             }
         }
     }
@@ -232,7 +236,9 @@ public class PluginManager {
      */
     public void onPause(boolean multitasking) {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
-            plugin.onPause(multitasking);
+            if (plugin != null) {
+                plugin.onPause(multitasking);
+            }
         }
     }
 
@@ -243,7 +249,9 @@ public class PluginManager {
      */
     public void onResume(boolean multitasking) {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
-            plugin.onResume(multitasking);
+            if (plugin != null) {
+                plugin.onResume(multitasking);
+            }
         }
     }
 
@@ -252,7 +260,9 @@ public class PluginManager {
      */
     public void onDestroy() {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
-            plugin.onDestroy();
+            if (plugin != null) {
+                plugin.onDestroy();
+            }
         }
     }
 
@@ -269,9 +279,11 @@ public class PluginManager {
             return obj;
         }
         for (CordovaPlugin plugin : this.pluginMap.values()) {
-            obj = plugin.onMessage(id, data);
-            if (obj != null) {
-                return obj;
+            if (plugin != null) {
+                obj = plugin.onMessage(id, data);
+                if (obj != null) {
+                    return obj;
+                }
             }
         }
         return null;
@@ -282,7 +294,9 @@ public class PluginManager {
      */
     public void onNewIntent(Intent intent) {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
-            plugin.onNewIntent(intent);
+            if (plugin != null) {
+                plugin.onNewIntent(intent);
+            }
         }
     }
 
@@ -320,15 +334,19 @@ public class PluginManager {
      */
     public void onReset() {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
-            plugin.onReset();
+            if (plugin != null) {
+                plugin.onReset();
+            }
         }
     }
 
     Uri remapUri(Uri uri) {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
-            Uri ret = plugin.remapUri(uri);
-            if (ret != null) {
-                return ret;
+            if (plugin != null) {
+                Uri ret = plugin.remapUri(uri);
+                if (ret != null) {
+                    return ret;
+                }
             }
         }
         return null;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message