Fix [ONOS-6374]: Replace HashMap with ConcurrentHashMap.
OpenFlowMeterProvider throws ClassCastException due to concurrent modification of a HashMap.
Replaced HashMap with ConcurrentHashMap to make it thread safe.
Change-Id: Ie2399b1d2da9d984ecc3cb4a4f8e839a33fb9cfa
diff --git a/providers/openflow/meter/src/main/java/org/onosproject/provider/of/meter/impl/OpenFlowMeterProvider.java b/providers/openflow/meter/src/main/java/org/onosproject/provider/of/meter/impl/OpenFlowMeterProvider.java
index 91e2f64..f186ef6 100644
--- a/providers/openflow/meter/src/main/java/org/onosproject/provider/of/meter/impl/OpenFlowMeterProvider.java
+++ b/providers/openflow/meter/src/main/java/org/onosproject/provider/of/meter/impl/OpenFlowMeterProvider.java
@@ -79,6 +79,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
+import java.util.concurrent.ConcurrentHashMap;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.openflow.controller.Dpid.uri;
@@ -115,7 +116,7 @@
private InternalMeterListener listener = new InternalMeterListener();
- private Map<Dpid, MeterStatsCollector> collectors = Maps.newHashMap();
+ private Map<Dpid, MeterStatsCollector> collectors = new ConcurrentHashMap<>();
private static final Set<Device.Type> NO_METER_SUPPORT =
ImmutableSet.copyOf(EnumSet.of(Device.Type.ROADM,