From 9cb15424336d3ff9d2229aad5e12a6cac2de9353 Mon Sep 17 00:00:00 2001 From: AKuznetsov Date: Tue, 10 Mar 2015 10:21:27 +0700 Subject: [PATCH] IGNITE-187 Fix for ConcurrentModificationException. --- .../org/apache/ignite/IgniteSystemProperties.java | 8 ++++++++ .../org/apache/ignite/internal/IgniteKernal.java | 24 +++++++++------------- .../visor/node/VisorGridConfiguration.java | 3 ++- 3 files changed, 20 insertions(+), 15 deletions(-) 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(); + } } 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 e : F.view(System.getProperties(), new P1() { - @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 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 entry : systemPropertiesSnapshot().entrySet()) + log.debug("System property [" + entry.getKey() + '=' + entry.getValue() + ']'); } /** 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()); -- 1.9.4.msysgit.0