From 1feaa7fed717d1f6e02508a280190c3d6914f95c Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Mon, 17 Nov 2014 22:11:21 -0800 Subject: [PATCH 1/2] CB-8031 Fix race condition that shows as ConcurrentModificationException --- .../src/org/apache/cordova/PluginManager.java | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/framework/src/org/apache/cordova/PluginManager.java b/framework/src/org/apache/cordova/PluginManager.java index 9ae5ce64..7ddf3005 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; From 7fbb2b195fb51f8c138e45702e2339f4ad51847f Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Wed, 26 Nov 2014 11:44:49 -0500 Subject: [PATCH 2/2] CB-8081 Allow gradle builds to use Java 6 instead of requiring 7 --- bin/templates/cordova/lib/plugin-build.gradle | 4 ++-- bin/templates/project/build.gradle | 4 ++-- framework/build.gradle | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/templates/cordova/lib/plugin-build.gradle b/bin/templates/cordova/lib/plugin-build.gradle index bf706c4c..fd4d8556 100644 --- a/bin/templates/cordova/lib/plugin-build.gradle +++ b/bin/templates/cordova/lib/plugin-build.gradle @@ -40,8 +40,8 @@ android { publishNonDefault true compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 + sourceCompatibility JavaVersion.VERSION_1_6 + targetCompatibility JavaVersion.VERSION_1_6 } sourceSets { diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle index b62a258f..63ecd810 100644 --- a/bin/templates/project/build.gradle +++ b/bin/templates/project/build.gradle @@ -85,8 +85,8 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 + sourceCompatibility JavaVersion.VERSION_1_6 + targetCompatibility JavaVersion.VERSION_1_6 } if (System.env.RELEASE_SIGNING_PROPERTIES_FILE) { diff --git a/framework/build.gradle b/framework/build.gradle index b9e9cdf7..e048edd9 100644 --- a/framework/build.gradle +++ b/framework/build.gradle @@ -45,8 +45,8 @@ android { publishNonDefault true compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 + sourceCompatibility JavaVersion.VERSION_1_6 + targetCompatibility JavaVersion.VERSION_1_6 } sourceSets {