Use Java 8 Map#compute when possible
Change-Id: Ida300c054449047096f355f09b3843e4934dcd18
diff --git a/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java b/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java
index bc8805d..3706b4b 100644
--- a/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java
+++ b/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java
@@ -30,7 +30,6 @@
import org.apache.felix.scr.annotations.Modified;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
-import org.onlab.util.NewConcurrentHashMap;
import org.onlab.util.Tools;
import org.onosproject.net.DeviceId;
import org.onosproject.net.flow.CompletedBatchOperation;
@@ -66,7 +65,6 @@
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
-import static org.apache.commons.lang3.concurrent.ConcurrentUtils.createIfAbsentUnchecked;
import static org.onosproject.net.flow.FlowRuleEvent.Type.RULE_REMOVED;
import static org.slf4j.LoggerFactory.getLogger;
@@ -163,10 +161,6 @@
}
}
- private static NewConcurrentHashMap<FlowId, List<StoredFlowEntry>> lazyEmptyFlowTable() {
- return NewConcurrentHashMap.ifNeeded();
- }
-
/**
* Returns the flow table for specified device.
*
@@ -174,8 +168,7 @@
* @return Map representing Flow Table of given device.
*/
private ConcurrentMap<FlowId, List<StoredFlowEntry>> getFlowTable(DeviceId deviceId) {
- return createIfAbsentUnchecked(flowEntries,
- deviceId, lazyEmptyFlowTable());
+ return flowEntries.computeIfAbsent(deviceId, k -> new ConcurrentHashMap<>());
}
private List<StoredFlowEntry> getFlowEntries(DeviceId deviceId, FlowId flowId) {
@@ -317,6 +310,7 @@
return null;
}
+ @Override
public void purgeFlowRule(DeviceId deviceId) {
flowEntries.remove(deviceId);
}