refactor #I5EU86 序列化类库fastjson转为jackson

This commit is contained in:
zendwang 2022-08-04 18:11:57 +08:00
parent 19bdab3b65
commit 1dde78b2a0
4 changed files with 17 additions and 15 deletions

View File

@ -45,7 +45,7 @@ public abstract class BaseZookeeperYmlFlowParser extends BaseYmlFlowParser{
JsonNode ruleObject = convertToJson(content);
parse(ruleObject.asText());
parse(ruleObject.toString());
zkParserHelper.listenZkNode(client);
}

View File

@ -20,11 +20,13 @@ import com.yomahub.liteflow.enums.ConditionTypeEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
import com.yomahub.liteflow.exception.*;
import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.util.JsonUtil;
import org.dom4j.Document;
import org.dom4j.Element;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import java.util.regex.Pattern;
@ -250,8 +252,8 @@ public class ParserHelper {
JsonNode nodeObject = nodeIterator.next();
id = nodeObject.get(ID).textValue();
name = nodeObject.hasNonNull(NAME) ? nodeObject.get(NAME).textValue() : "";
clazz = nodeObject.hasNonNull(_CLASS) ? nodeObject.get(NAME).textValue() : "";;
type = nodeObject.hasNonNull(TYPE) ? nodeObject.get(TYPE).textValue() : "";
clazz = nodeObject.hasNonNull(_CLASS) ? nodeObject.get(_CLASS).textValue() : "";;
type = nodeObject.hasNonNull(TYPE) ? nodeObject.get(TYPE).textValue() : null;
script = nodeObject.hasNonNull(VALUE) ? nodeObject.get(VALUE).textValue() : "";
file = nodeObject.hasNonNull(FILE) ? nodeObject.get(FILE).textValue() : "";
@ -299,10 +301,10 @@ public class ParserHelper {
JsonNode condNode = iterator.next();
conditionType = ConditionTypeEnum.getEnumByCode(condNode.get(TYPE).textValue());
condValueStr = condNode.get(VALUE).textValue();
errorResume = condNode.get(ERROR_RESUME).textValue();
group = condNode.get(GROUP).textValue();
any = condNode.get(ANY).textValue();
threadExecutorClass = condNode.get(THREAD_EXECUTOR_CLASS).textValue();
errorResume = condNode.hasNonNull(ERROR_RESUME) ? condNode.get(ERROR_RESUME).textValue() : "";
group = condNode.hasNonNull(GROUP) ? condNode.get(GROUP).textValue() : "";
any = condNode.hasNonNull(ANY) ? condNode.get(ANY).textValue() : "";
threadExecutorClass = condNode.hasNonNull(THREAD_EXECUTOR_CLASS) ? condNode.get(THREAD_EXECUTOR_CLASS).textValue() : "";
ChainPropBean chainPropBean = new ChainPropBean()
.setCondValueStr(condValueStr)

View File

@ -36,8 +36,8 @@ public class JsonUtil {
try {
return objectMapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
String errMsg = StrUtil.format("Error while writing value as string[{}]",object.getClass().getName());
LOG.error(errMsg);
String errMsg = StrUtil.format("Error while writing value as string[{}],reason: {}", object.getClass().getName(), e.getMessage());
LOG.error(e.getMessage(), e);
throw new JsonProcessException(errMsg);
}
}
@ -49,8 +49,8 @@ public class JsonUtil {
try {
return objectMapper.readTree(text);
} catch (IOException e) {
String errMsg = StrUtil.format("Error while parsing text [{}]",text);
LOG.error(errMsg);
String errMsg = StrUtil.format("Error while parsing text [{}],reason: {}", text, e.getMessage());
LOG.error(e.getMessage(), e);
throw new JsonProcessException(errMsg);
}
}

View File

@ -3,19 +3,19 @@
"chain": [
{
"name": "chain3",
"value": "THEN(e,d)",
"value": "THEN(e,d)"
},
{
"name": "chain2",
"value": "THEN(b, a, chain3)",
"value": "THEN(b, a, chain3)"
},
{
"name": "chain1",
"value": "THEN(a, b, c, chain2)",
"value": "THEN(a, b, c, chain2)"
},
{
"name": "c",
"value": "THEN(d, e)",
"value": "THEN(d, e)"
}
]
}