From 56ee220a68c1f69ed6cf4af213eee5027797dceb Mon Sep 17 00:00:00 2001 From: onewe Date: Tue, 28 Jun 2022 13:46:34 +0800 Subject: [PATCH] [ISSUES #8635] fix a NPE when call the shutdown method (#8636) * [ISSUES #8635] fix a NPE when call the shutdown method Close #8635 * [ISSUES #8635] remove init judgment --- .../consistency/persistent/raft/RaftCore.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftCore.java b/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftCore.java index ffbde3fb4..188442d5b 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftCore.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/raft/RaftCore.java @@ -469,10 +469,16 @@ public class RaftCore implements Closeable { 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(); }