Madan Jampani
Committed by Gerrit Code Review

Fixes NPE in AtomixLeaderElector

Change-Id: I0db39b4e09af10f92fe06ba8c7372994e776a6e2
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
15 */ 15 */
16 package org.onosproject.store.primitives.resources.impl; 16 package org.onosproject.store.primitives.resources.impl;
17 17
18 -import io.atomix.catalyst.util.Listener;
19 import io.atomix.copycat.client.CopycatClient; 18 import io.atomix.copycat.client.CopycatClient;
20 import io.atomix.resource.AbstractResource; 19 import io.atomix.resource.AbstractResource;
21 import io.atomix.resource.ResourceTypeInfo; 20 import io.atomix.resource.ResourceTypeInfo;
...@@ -50,10 +49,9 @@ import com.google.common.collect.Sets; ...@@ -50,10 +49,9 @@ import com.google.common.collect.Sets;
50 public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector> 49 public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector>
51 implements AsyncLeaderElector { 50 implements AsyncLeaderElector {
52 private final Set<Consumer<Change<Leadership>>> leadershipChangeListeners = 51 private final Set<Consumer<Change<Leadership>>> leadershipChangeListeners =
53 - Sets.newConcurrentHashSet(); 52 + Sets.newIdentityHashSet();
54 53
55 public static final String CHANGE_SUBJECT = "leadershipChangeEvents"; 54 public static final String CHANGE_SUBJECT = "leadershipChangeEvents";
56 - private Listener<Change<Leadership>> listener;
57 55
58 public AtomixLeaderElector(CopycatClient client, Properties properties) { 56 public AtomixLeaderElector(CopycatClient client, Properties properties) {
59 super(client, properties); 57 super(client, properties);
...@@ -127,7 +125,7 @@ public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector> ...@@ -127,7 +125,7 @@ public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector>
127 125
128 @Override 126 @Override
129 public synchronized CompletableFuture<Void> removeChangeListener(Consumer<Change<Leadership>> consumer) { 127 public synchronized CompletableFuture<Void> removeChangeListener(Consumer<Change<Leadership>> consumer) {
130 - if (leadershipChangeListeners.remove(listener) && leadershipChangeListeners.isEmpty()) { 128 + if (leadershipChangeListeners.remove(consumer) && leadershipChangeListeners.isEmpty()) {
131 return submit(new Unlisten()).thenApply(v -> null); 129 return submit(new Unlisten()).thenApply(v -> null);
132 } 130 }
133 return CompletableFuture.completedFuture(null); 131 return CompletableFuture.completedFuture(null);
......