IGNITE-187 Fix for ConcurrentModificationException.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/9cb15424 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/9cb15424 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/9cb15424 Branch: refs/heads/ignite-141-2 Commit: 9cb15424336d3ff9d2229aad5e12a6cac2de9353 Parents: 57aa945 Author: AKuznetsov <akuznet...@gridgain.com> Authored: Tue Mar 10 10:21:27 2015 +0700 Committer: AKuznetsov <akuznet...@gridgain.com> Committed: Tue Mar 10 10:21:27 2015 +0700 ---------------------------------------------------------------------- .../apache/ignite/IgniteSystemProperties.java | 8 +++++++ .../apache/ignite/internal/IgniteKernal.java | 24 ++++++++------------ .../visor/node/VisorGridConfiguration.java | 3 ++- 3 files changed, 20 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9cb15424/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java index d454e76..0b0d1fd 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java @@ -21,6 +21,7 @@ import org.jetbrains.annotations.*; import javax.net.ssl.*; import java.lang.management.*; +import java.util.*; /** * Contains constants for all system properties and environmental variables in Ignite. These @@ -474,4 +475,11 @@ public final class IgniteSystemProperties { return res; } + + /** + * @return Thread safe copy of system properties. + */ + public static Properties systemPropertiesSnapshot() { + return (Properties)System.getProperties().clone(); + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9cb15424/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java index 81bbf89..5b47c90 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java @@ -1118,22 +1118,18 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable { try { // Stick all system properties into node's attributes overwriting any // identical names from environment properties. - for (Map.Entry<Object, Object> e : F.view(System.getProperties(), new P1<Object>() { - @Override public boolean apply(Object o) { - String name = (String)o; - - return incProps == null || U.containsStringArray(incProps, name, true) || - U.isVisorRequiredProperty(name); - } - }).entrySet()) { + for (Map.Entry<Object, Object> e : systemPropertiesSnapshot().entrySet()) { String key = (String)e.getKey(); - Object val = ctx.nodeAttribute(key); + if (incProps == null || U.containsStringArray(incProps, key, true) || + U.isVisorRequiredProperty(key)) { + Object val = ctx.nodeAttribute(key); - if (val != null && !val.equals(e.getValue())) - U.warn(log, "System property will override environment variable with the same name: " + key); + if (val != null && !val.equals(e.getValue())) + U.warn(log, "System property will override environment variable with the same name: " + key); - ctx.addNodeAttribute(key, e.getValue()); + ctx.addNodeAttribute(key, e.getValue()); + } } if (log.isDebugEnabled()) @@ -1912,8 +1908,8 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable { assert log != null; if (log.isDebugEnabled()) - for (Object key : U.asIterable(System.getProperties().keys())) - log.debug("System property [" + key + '=' + System.getProperty((String) key) + ']'); + for (Map.Entry<Object, Object> entry : systemPropertiesSnapshot().entrySet()) + log.debug("System property [" + entry.getKey() + '=' + entry.getValue() + ']'); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9cb15424/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java index cc6ae63..0f7ca24 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java @@ -27,6 +27,7 @@ import java.io.*; import java.util.*; import static java.lang.System.*; +import static org.apache.ignite.IgniteSystemProperties.*; import static org.apache.ignite.internal.visor.util.VisorTaskUtils.*; /** @@ -117,7 +118,7 @@ public class VisorGridConfiguration implements Serializable { igfss = VisorIgfsConfiguration.list(c.getFileSystemConfiguration()); streamers = VisorStreamerConfiguration.list(c.getStreamerConfiguration()); env = new HashMap<>(getenv()); - sysProps = getProperties(); + sysProps = systemPropertiesSnapshot(); atomic = VisorAtomicConfiguration.from(c.getAtomicConfiguration()); txCfg = VisorTransactionConfiguration.from(c.getTransactionConfiguration()); qryCfg = VisorQueryConfiguration.from(c.getQueryConfiguration());