解决zkYml解析的bug

This commit is contained in:
bryan31
2021-04-08 11:37:32 +08:00
parent 28afb47497
commit 7bc9c7d1bb
2 changed files with 6 additions and 3 deletions

View File

@@ -24,7 +24,7 @@ public abstract class YmlFlowParser extends JsonFlowParser{
parse(ruleObject.toJSONString());
}
private JSONObject convertToJson(String yamlString) {
protected JSONObject convertToJson(String yamlString) {
Yaml yaml= new Yaml();
Map<String, Object> map = yaml.load(yamlString);
JSONObject jsonObject = new JSONObject(map);

View File

@@ -1,6 +1,7 @@
package com.yomahub.liteflow.parser;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.yomahub.liteflow.exception.ParseException;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -45,12 +46,14 @@ public class ZookeeperYmlFlowParser extends YmlFlowParser{
String content = new String(client.getData().forPath(nodePath));
if (StrUtil.isBlank(content)) {
String error = MessageFormat.format("the node[{0}] value is empty", nodePath);
throw new ParseException(error);
}
parse(content);
JSONObject ruleObject = convertToJson(content);
parse(ruleObject.toJSONString());
final NodeCache cache = new NodeCache(client,nodePath);