cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject [1/3] cordova-amazon-fireos git commit: CB-8031 Fix race condition that shows as ConcurrentModificationException
Date Sat, 06 Dec 2014 15:55:46 GMT
Repository: cordova-amazon-fireos
Updated Branches:
  refs/heads/master 4142cbb57 -> b84610a6c


CB-8031 Fix race condition that shows as ConcurrentModificationException

Conflicts:

	framework/src/org/apache/cordova/PluginManager.java


Project: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/commit/54784a09
Tree: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/tree/54784a09
Diff: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/diff/54784a09

Branch: refs/heads/master
Commit: 54784a0948d3b3bd216383804e5e0729b5abf4b5
Parents: 4142cbb
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Mon Nov 17 22:11:21 2014 -0800
Committer: Ajitha <ajithas@amazon.com>
Committed: Mon Dec 1 12:59:24 2014 +0530

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


http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/54784a09/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 2af8f45..a8b4587 100755
--- a/framework/src/org/apache/cordova/PluginManager.java
+++ b/framework/src/org/apache/cordova/PluginManager.java
@@ -115,8 +115,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);
             }
         }
     }
@@ -307,7 +311,9 @@ public class PluginManager {
      */
     public void onPause(boolean multitasking) {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
-            plugin.onPause(multitasking);
+            if (plugin != null) {
+                plugin.onPause(multitasking);
+            }
         }
     }
 
@@ -318,7 +324,9 @@ public class PluginManager {
      */
     public void onResume(boolean multitasking) {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
-            plugin.onResume(multitasking);
+            if (plugin != null) {
+                plugin.onResume(multitasking);
+            }
         }
     }
 
@@ -329,7 +337,9 @@ public class PluginManager {
         try {
             for (CordovaPlugin plugin : this.pluginMap.values()) {
                 Log.d(TAG, "In destroy");
-                plugin.onDestroy();
+                if (plugin != null) {
+                    plugin.onDestroy();
+		}
             }
         } catch (Exception e) {
             Log.e(TAG, e.getMessage());
@@ -351,9 +361,11 @@ public class PluginManager {
         }
 
         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;
@@ -364,7 +376,9 @@ public class PluginManager {
      */
     public void onNewIntent(Intent intent) {
         for (CordovaPlugin plugin : this.pluginMap.values()) {
-            plugin.onNewIntent(intent);
+            if (plugin != null) {
+                plugin.onNewIntent(intent);
+            }
         }
     }
 
@@ -403,15 +417,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