Skip to content

Commit

Permalink
dashboard: Fix NoNodeException problem of FlowRuleZookeeperProvider e…
Browse files Browse the repository at this point in the history
…xample (alibaba#1352)
  • Loading branch information
WongTheo authored Mar 22, 2020
1 parent 87f95ad commit 8f0cb2d
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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;

Expand All @@ -36,6 +37,10 @@ public class FlowRuleZookeeperProvider implements DynamicRuleProvider<List<FlowR
@Override
public List<FlowRuleEntity> 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<>();
Expand Down

0 comments on commit 8f0cb2d

Please sign in to comment.