From 8f0cb2d24a53efe8afd3fad4dff58c6aacca4002 Mon Sep 17 00:00:00 2001 From: WongTheo <61610981+WongTheo@users.noreply.github.com> Date: Sun, 22 Mar 2020 17:58:18 +0800 Subject: [PATCH] dashboard: Fix NoNodeException problem of FlowRuleZookeeperProvider example (#1352) --- .../dashboard/rule/zookeeper/FlowRuleZookeeperProvider.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sentinel-dashboard/src/test/java/com/alibaba/csp/sentinel/dashboard/rule/zookeeper/FlowRuleZookeeperProvider.java b/sentinel-dashboard/src/test/java/com/alibaba/csp/sentinel/dashboard/rule/zookeeper/FlowRuleZookeeperProvider.java index 727b5410..cbb94f88 100644 --- a/sentinel-dashboard/src/test/java/com/alibaba/csp/sentinel/dashboard/rule/zookeeper/FlowRuleZookeeperProvider.java +++ b/sentinel-dashboard/src/test/java/com/alibaba/csp/sentinel/dashboard/rule/zookeeper/FlowRuleZookeeperProvider.java @@ -19,6 +19,7 @@ import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; import com.alibaba.csp.sentinel.dashboard.rule.DynamicRuleProvider; import com.alibaba.csp.sentinel.datasource.Converter; import org.apache.curator.framework.CuratorFramework; +import org.apache.zookeeper.data.Stat; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -36,6 +37,10 @@ public class FlowRuleZookeeperProvider implements DynamicRuleProvider getRules(String appName) throws Exception { String zkPath = ZookeeperConfigUtil.getPath(appName); + Stat stat = zkClient.checkExists().forPath(zkPath); + if(stat == null){ + return new ArrayList<>(0); + } byte[] bytes = zkClient.getData().forPath(zkPath); if (null == bytes || bytes.length == 0) { return new ArrayList<>();