Repository: asterixdb Updated Branches: refs/heads/master 2e3c52015 -> e2fa196f8
[ASTERIXDB-2091][HYR][CLUS] Fix unsafe concurrent access to config on NC registration Change-Id: I399d26d128794a0a52eff419f59ca28d64b17375 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2007 Sonar-Qube: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> Contrib: Jenkins <[email protected]> Integration-Tests: Jenkins <[email protected]> Reviewed-by: Murtadha Hubail <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/e2fa196f Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/e2fa196f Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/e2fa196f Branch: refs/heads/master Commit: e2fa196f8e714acd9d6c7e85159cc4d20f0dfe9e Parents: 2e3c520 Author: Michael Blow <[email protected]> Authored: Thu Sep 14 01:46:58 2017 -0400 Committer: Michael Blow <[email protected]> Committed: Thu Sep 14 11:29:49 2017 -0700 ---------------------------------------------------------------------- .../hyracks/control/common/config/ConfigManager.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/e2fa196f/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/config/ConfigManager.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/config/ConfigManager.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/config/ConfigManager.java index 2e04e13..d13b5e6 100644 --- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/config/ConfigManager.java +++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/config/ConfigManager.java @@ -71,7 +71,8 @@ public class ConfigManager implements IConfigManager, Serializable { private CompositeMap<IOption, Object> configurationMap = new CompositeMap<>(definedMap, defaultMap, new NoOpMapMutator()); private EnumMap<Section, Map<String, IOption>> sectionMap = new EnumMap<>(Section.class); - private TreeMap<String, Map<IOption, Object>> nodeSpecificMap = new TreeMap<>(); + @SuppressWarnings("squid:S1948") // TreeMap is serializable, and therefore so is its synchronized map + private Map<String, Map<IOption, Object>> nodeSpecificMap = Collections.synchronizedMap(new TreeMap<>()); private transient ArrayListValuedHashMap<IOption, IConfigSetter> optionSetters = new ArrayListValuedHashMap<>(); private final String[] args; private ConfigManagerApplicationConfig appConfig = new ConfigManagerApplicationConfig(this); @@ -457,10 +458,13 @@ public class ConfigManager implements IConfigManager, Serializable { } for (Map.Entry<String, Map<IOption, Object>> nodeMapEntry : nodeSpecificMap.entrySet()) { String section = Section.NC.sectionName() + "/" + nodeMapEntry.getKey(); - for (Map.Entry<IOption, Object> entry : nodeMapEntry.getValue().entrySet()) { - if (entry.getValue() != null) { - final IOption option = entry.getKey(); - ini.add(section, option.ini(), option.type().serializeToIni(entry.getValue())); + final Map<IOption, Object> nodeValueMap = nodeMapEntry.getValue(); + synchronized (nodeValueMap) { + for (Map.Entry<IOption, Object> entry : nodeValueMap.entrySet()) { + if (entry.getValue() != null) { + final IOption option = entry.getKey(); + ini.add(section, option.ini(), option.type().serializeToIni(entry.getValue())); + } } } }
