Skip to content

Commit

Permalink
[ISSUES alibaba#8635] fix a NPE when call the shutdown method
Browse files Browse the repository at this point in the history
  • Loading branch information
onewe committed Jun 27, 2022
1 parent f53d50c commit f2ba1c7
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -464,15 +464,24 @@ public void onDelete(String datumKey, RaftPeer source) throws Exception {
@Override
public void shutdown() throws NacosException {
this.stopWork = true;
if (!initialized) {
return;
}
this.raftStore.shutdown();
this.peers.shutdown();
Loggers.RAFT.warn("start to close old raft protocol!!!");
Loggers.RAFT.warn("stop old raft protocol task for notifier");
NotifyCenter.deregisterSubscriber(notifier);
Loggers.RAFT.warn("stop old raft protocol task for master task");
masterTask.cancel(true);
Loggers.RAFT.warn("stop old raft protocol task for heartbeat task");
heartbeatTask.cancel(true);
if (masterTask != null) {
Loggers.RAFT.warn("stop old raft protocol task for master task");
masterTask.cancel(true);
}

if (heartbeatTask != null) {
Loggers.RAFT.warn("stop old raft protocol task for heartbeat task");
heartbeatTask.cancel(true);
}

Loggers.RAFT.warn("clean old cache datum for old raft");
datums.clear();
}
Expand Down

0 comments on commit f2ba1c7

Please sign in to comment.