From 35edfd43836ed2566881e28c8620162f3a9737da Mon Sep 17 00:00:00 2001 From: nkorange Date: Wed, 3 Apr 2019 17:07:18 +0800 Subject: [PATCH] #961 init cluster after instantiate cluster --- .../src/main/java/com/alibaba/nacos/naming/core/Cluster.java | 4 +++- .../src/main/java/com/alibaba/nacos/naming/core/Service.java | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/Cluster.java b/naming/src/main/java/com/alibaba/nacos/naming/core/Cluster.java index c4bf49927..1001983fe 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/core/Cluster.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/core/Cluster.java @@ -99,7 +99,9 @@ public class Cluster extends com.alibaba.nacos.api.naming.pojo.Cluster implement } public void destroy() { - checkTask.setCancelled(true); + if (checkTask != null) { + checkTask.setCancelled(true); + } } public HealthCheckTask getHealthCheckTask() { diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java index 170a8ded7..71d99ffc4 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java @@ -217,6 +217,7 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement instance.getClusterName(), instance.toJSON()); Cluster cluster = new Cluster(instance.getClusterName()); cluster.setService(this); + cluster.init(); getClusterMap().put(instance.getClusterName(), cluster); }