Fixes NPE in AtomixLeaderElector
Change-Id: I0db39b4e09af10f92fe06ba8c7372994e776a6e2
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixLeaderElector.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixLeaderElector.java
index 95a5911..69f43e2 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixLeaderElector.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixLeaderElector.java
@@ -15,7 +15,6 @@
*/
package org.onosproject.store.primitives.resources.impl;
-import io.atomix.catalyst.util.Listener;
import io.atomix.copycat.client.CopycatClient;
import io.atomix.resource.AbstractResource;
import io.atomix.resource.ResourceTypeInfo;
@@ -50,10 +49,9 @@
public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector>
implements AsyncLeaderElector {
private final Set<Consumer<Change<Leadership>>> leadershipChangeListeners =
- Sets.newConcurrentHashSet();
+ Sets.newIdentityHashSet();
public static final String CHANGE_SUBJECT = "leadershipChangeEvents";
- private Listener<Change<Leadership>> listener;
public AtomixLeaderElector(CopycatClient client, Properties properties) {
super(client, properties);
@@ -127,7 +125,7 @@
@Override
public synchronized CompletableFuture<Void> removeChangeListener(Consumer<Change<Leadership>> consumer) {
- if (leadershipChangeListeners.remove(listener) && leadershipChangeListeners.isEmpty()) {
+ if (leadershipChangeListeners.remove(consumer) && leadershipChangeListeners.isEmpty()) {
return submit(new Unlisten()).thenApply(v -> null);
}
return CompletableFuture.completedFuture(null);