Use ConcurrentHashMap.newKeySet() 46/85146/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 16 Oct 2019 11:51:16 +0000 (13:51 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 16 Oct 2019 11:51:16 +0000 (13:51 +0200)
Instead of using Sets.newConcurrentHashSet(), use the utility
method provided by ConcurrentHashMap.

Change-Id: I796e8b6b260f865138a2716f1bb61c983972a4d4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java

index f8dd5c6..e53523b 100644 (file)
@@ -8,13 +8,13 @@
 package org.opendaylight.controller.clustering.it.provider;
 
 import com.google.common.base.Stopwatch;
-import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.Collection;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -98,10 +98,9 @@ public class CarProvider implements CarService {
     private final CarEntityOwnershipListener ownershipListener = new CarEntityOwnershipListener();
     private final AtomicBoolean registeredListener = new AtomicBoolean();
 
-    private final Collection<ListenerRegistration<?>> carsDclRegistrations =
-            Sets.newConcurrentHashSet();
-    private final Collection<ListenerRegistration<CarDataTreeChangeListener>> carsDtclRegistrations =
-            Sets.newConcurrentHashSet();
+    private final Set<ListenerRegistration<?>> carsDclRegistrations = ConcurrentHashMap.newKeySet();
+    private final Set<ListenerRegistration<CarDataTreeChangeListener>> carsDtclRegistrations =
+            ConcurrentHashMap.newKeySet();
 
     private volatile Thread testThread;
     private volatile boolean stopThread;

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.