Prevent concurrent access to the port map
Change-Id: Icaadf9dc52892c6475f8c65201a104df86c72d50
(cherry picked from commit 44ba937e6b50a1a4274d3e8634be7de282ce7b64)
diff --git a/providers/lldpcommon/src/main/java/org/onosproject/provider/lldpcommon/LinkDiscovery.java b/providers/lldpcommon/src/main/java/org/onosproject/provider/lldpcommon/LinkDiscovery.java
index 3631e16..317fda8 100644
--- a/providers/lldpcommon/src/main/java/org/onosproject/provider/lldpcommon/LinkDiscovery.java
+++ b/providers/lldpcommon/src/main/java/org/onosproject/provider/lldpcommon/LinkDiscovery.java
@@ -17,10 +17,8 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
-
import io.netty.util.Timeout;
import io.netty.util.TimerTask;
-
import io.netty.util.internal.StringUtil;
import org.onlab.packet.Ethernet;
import org.onlab.packet.MacAddress;
@@ -35,14 +33,14 @@
import org.onosproject.net.PortNumber;
import org.onosproject.net.link.DefaultLinkDescription;
import org.onosproject.net.link.LinkDescription;
+import org.onosproject.net.link.ProbedLinkProvider;
import org.onosproject.net.packet.DefaultOutboundPacket;
import org.onosproject.net.packet.OutboundPacket;
import org.onosproject.net.packet.PacketContext;
-import org.onosproject.net.link.ProbedLinkProvider;
import org.slf4j.Logger;
import java.nio.ByteBuffer;
-import java.util.HashMap;
+import java.util.Map;
import static com.google.common.base.Strings.isNullOrEmpty;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
@@ -72,8 +70,7 @@
private volatile boolean isStopped;
// Set of ports to be probed
- private final HashMap<Long, String> portMap = Maps.newHashMap();
-
+ private final Map<Long, String> portMap = Maps.newConcurrentMap();
/**
* Instantiates discovery manager for the given physical switch. Creates a
* generic LLDP packet that will be customized for the port it is sent out on.