fix potential race condition
Change-Id: I0bf9df79691e9b08af981348a75886b053404add
diff --git a/src/main/java/org/onosproject/segmentrouting/IpHandler.java b/src/main/java/org/onosproject/segmentrouting/IpHandler.java
index 34368be..19153b4 100644
--- a/src/main/java/org/onosproject/segmentrouting/IpHandler.java
+++ b/src/main/java/org/onosproject/segmentrouting/IpHandler.java
@@ -109,13 +109,9 @@
Ip4Address destIpAddress = Ip4Address.valueOf(ipPacket.getDestinationAddress());
- if (ipPacketQueue.get(destIpAddress) == null) {
- ConcurrentLinkedQueue<IPv4> queue = new ConcurrentLinkedQueue<>();
- queue.add(ipPacket);
- ipPacketQueue.put(destIpAddress, queue);
- } else {
- ipPacketQueue.get(destIpAddress).add(ipPacket);
- }
+ ipPacketQueue
+ .computeIfAbsent(destIpAddress, a -> new ConcurrentLinkedQueue<>())
+ .add(ipPacket);
}
/**