From 5ae47e8c3c4cd17ca6abc75e72be0338b0ceaf96 Mon Sep 17 00:00:00 2001 From: Jeff Mesnil Date: Wed, 18 Jan 2017 15:56:35 +0100 Subject: [PATCH] ARTEMIS-962 Fix CME when parsing system properties Add synchronized block against the properties before iterating on them. JIRA: https://issues.apache.org/jira/browse/ARTEMIS-926 --- .../core/config/impl/ConfigurationImpl.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java index 2d4be39bff..bfa6c406a6 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java @@ -308,22 +308,23 @@ public class ConfigurationImpl implements Configuration, Serializable { @Override public Configuration parseSystemProperties(Properties properties) throws Exception { + synchronized (properties) { + Map beanProperties = new HashMap<>(); - Map beanProperties = new HashMap<>(); - - for (Map.Entry entry : properties.entrySet()) { - if (entry.getKey().toString().startsWith(systemPropertyPrefix)) { - String key = entry.getKey().toString().substring(systemPropertyPrefix.length()); - logger.debug("Setting up config, " + key + "=" + entry.getValue()); - beanProperties.put(key, entry.getValue()); + for (Map.Entry entry : properties.entrySet()) { + if (entry.getKey().toString().startsWith(systemPropertyPrefix)) { + String key = entry.getKey().toString().substring(systemPropertyPrefix.length()); + logger.debug("Setting up config, " + key + "=" + entry.getValue()); + beanProperties.put(key, entry.getValue()); + } } - } - if (!beanProperties.isEmpty()) { - BeanSupport.setData(this, beanProperties); - } + if (!beanProperties.isEmpty()) { + BeanSupport.setData(this, beanProperties); + } - return this; + return this; + } } @Override