Use ConcurrentHashMap.newKeySet() 82/85182/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 16 Oct 2019 11:51:16 +0000 (13:51 +0200)
committerRobert Varga <nite@hq.sk>
Sat, 2 Nov 2019 07:42:54 +0000 (07:42 +0000)
Instead of using Sets.newConcurrentHashSet(), use the utility
method provided by ConcurrentHashMap.

Change-Id: I796e8b6b260f865138a2716f1bb61c983972a4d4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0613036fe3fe2a2241eac823ab904d18c6cdaf41)

opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java

index a6f154bfcde7282b7b0bdb6c0d5a7166bdbd3238..3cf4604f43e945bf85b9eb62c70c77766aed0661 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;
@@ -97,10 +97,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;