Ayaka Koshibe
Committed by Gerrit Code Review

Fix NPE for election app when handling CANDIDATE events. Also disables running

for leadership automatically at startup.

Change-Id: I27f297fdd4b62f9cd345df88a772f76ade56d350
...@@ -68,7 +68,6 @@ public class ElectionTest { ...@@ -68,7 +68,6 @@ public class ElectionTest {
68 localControllerNode = clusterService.getLocalNode(); 68 localControllerNode = clusterService.getLocalNode();
69 69
70 leadershipService.addListener(leadershipEventListener); 70 leadershipService.addListener(leadershipEventListener);
71 - leadershipService.runForLeadership(appId.name());
72 } 71 }
73 72
74 @Deactivate 73 @Deactivate
...@@ -90,6 +89,9 @@ public class ElectionTest { ...@@ -90,6 +89,9 @@ public class ElectionTest {
90 public void event(LeadershipEvent event) { 89 public void event(LeadershipEvent event) {
91 90
92 91
92 + if (event.type().equals(LeadershipEvent.Type.CANDIDATES_CHANGED)) {
93 + return;
94 + }
93 if (!event.subject().topic().equals(appId.name())) { 95 if (!event.subject().topic().equals(appId.name())) {
94 return; // Not our topic: ignore 96 return; // Not our topic: ignore
95 } 97 }
......