diff --git a/faroe/core/src/main/java/org/n52/faroe/SettingsServiceImpl.java b/faroe/core/src/main/java/org/n52/faroe/SettingsServiceImpl.java index eb4a676fb..279735810 100644 --- a/faroe/core/src/main/java/org/n52/faroe/SettingsServiceImpl.java +++ b/faroe/core/src/main/java/org/n52/faroe/SettingsServiceImpl.java @@ -31,6 +31,7 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; +import java.util.TreeMap; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -65,8 +66,8 @@ public class SettingsServiceImpl implements SettingsService { private static final Logger LOG = LoggerFactory.getLogger(SettingsServiceImpl.class); private final Map> configurableObjects = new HashMap<>(); private final ReadWriteLock configurableObjectsLock = new ReentrantReadWriteLock(); - private Set> definitions; - private Map> definitionByKey; + private Set> definitions = new HashSet<>(); + private Map> definitionByKey = new TreeMap<>(); private SettingsDao settingsManagerDao; private SettingValueFactory settingValueFactory; private EventBus serviceEventBus; @@ -90,14 +91,11 @@ public void setSettingsManagerDao(SettingsDao settingsManagerDao) { @Inject public void setSettingDefinitions(Optional>> def) { + this.definitions.clear(); + this.definitionByKey.clear(); if (def.isPresent()) { Collection> defs = def.get(); - this.definitions = new HashSet<>(defs.size()); - this.definitionByKey = new HashMap<>(defs.size()); addSettings(defs); - } else { - this.definitions = new HashSet<>(0); - this.definitionByKey = new HashMap<>(0); } }