Fix nasty race condition in the MeterStore
This situation is very specific of the EC maps which
can receive updates from the peers immedietaly due
to the bootstrap process.
Change-Id: I6b6087fbf907d8a6fb0bb8f807fe210e0f1ab571
diff --git a/core/store/dist/src/main/java/org/onosproject/store/meter/impl/DistributedMeterStore.java b/core/store/dist/src/main/java/org/onosproject/store/meter/impl/DistributedMeterStore.java
index b94375c..30da74d 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/meter/impl/DistributedMeterStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/meter/impl/DistributedMeterStore.java
@@ -114,7 +114,8 @@
// Meters id related objects
private static final String AVAILABLEMETERIDSTORE = "onos-meters-available-store";
- protected ConcurrentMap<MeterTableKey, DistributedSet<MeterKey>> availableMeterIds;
+ protected final ConcurrentMap<MeterTableKey, DistributedSet<MeterKey>> availableMeterIds =
+ new ConcurrentHashMap<>();
private static final String METERIDSTORE = "onos-meters-id-store";
private AtomicCounterMap<MeterTableKey> meterIdGenerators;
@@ -177,8 +178,6 @@
.withSerializer(APP_KRYO_BUILDER).build();
metersFeatures.addListener(featuresMapListener);
- availableMeterIds = new ConcurrentHashMap<>();
-
meterIdGenerators = storageService.<MeterTableKey>atomicCounterMapBuilder()
.withName(METERIDSTORE)
.withSerializer(Serializer.using(KryoNamespaces.API,