Skip to content

Commit

Permalink
init definition map/set by default and clear before adding set
Browse files Browse the repository at this point in the history
  • Loading branch information
CarstenHollmann committed Jul 19, 2022
1 parent ad5b8c4 commit 228332d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions faroe/core/src/main/java/org/n52/faroe/SettingsServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -65,8 +66,8 @@ public class SettingsServiceImpl implements SettingsService {
private static final Logger LOG = LoggerFactory.getLogger(SettingsServiceImpl.class);
private final Map<String, Set<ConfigurableObject>> configurableObjects = new HashMap<>();
private final ReadWriteLock configurableObjectsLock = new ReentrantReadWriteLock();
private Set<SettingDefinition<?>> definitions;
private Map<String, SettingDefinition<?>> definitionByKey;
private Set<SettingDefinition<?>> definitions = new HashSet<>();
private Map<String, SettingDefinition<?>> definitionByKey = new TreeMap<>();
private SettingsDao settingsManagerDao;
private SettingValueFactory settingValueFactory;
private EventBus serviceEventBus;
Expand All @@ -90,14 +91,11 @@ public void setSettingsManagerDao(SettingsDao settingsManagerDao) {

@Inject
public void setSettingDefinitions(Optional<Collection<SettingDefinition<?>>> def) {
this.definitions.clear();
this.definitionByKey.clear();
if (def.isPresent()) {
Collection<SettingDefinition<?>> 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);
}
}

Expand Down

0 comments on commit 228332d

Please sign in to comment.