Skip to content

Commit 9b42438

Browse files
mzazaipscjabolina
authored andcommitted
Fix: isLeader() returns true, even if leader is null
1 parent fb70832 commit 9b42438

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/org/jgroups/protocols/raft/RAFT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public int processingQueueSize() {
261261
@ManagedAttribute(description="The current leader (can be null if there is currently no leader) ")
262262
public Address leader() {return raft_state.leader();}
263263
public RAFT leader(Address new_leader) {this.raft_state.setLeader(new_leader); return this;}
264-
public boolean isLeader() {return Objects.equals(leader(), local_addr);}
264+
public boolean isLeader() {return leader() != null && Objects.equals(leader(), local_addr);}
265265

266266
public RAFT stateMachine(StateMachine sm) {
267267
boolean load = state_machine == null && !state_machine_loaded;

0 commit comments

Comments
 (0)