diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/entity/flow/Condition.java b/liteflow-core/src/main/java/com/yomahub/liteflow/entity/flow/Condition.java index 67733cc40..cbe1e4ec1 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/entity/flow/Condition.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/entity/flow/Condition.java @@ -22,8 +22,8 @@ public class Condition { private List nodeList; - //只在when类型下有效,以区分当when调用链调用失败时是否继续往下执行 默认true继续执行 - private boolean errorResume = true; + //只在when类型下有效,以区分当when调用链调用失败时是否继续往下执行 默认false不继续执行 + private boolean errorResume = false; //只在when类型下有效,用于不同node进行同组合并,相同的组会进行合并,不同的组不会进行合并 private String group = LocalDefaultFlowConstant.DEFAULT; diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/JsonFlowParser.java b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/JsonFlowParser.java index 6f1d55fbb..2557a8121 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/JsonFlowParser.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/JsonFlowParser.java @@ -145,7 +145,7 @@ public abstract class JsonFlowParser extends FlowParser { group = LocalDefaultFlowConstant.DEFAULT; } if (StrUtil.isBlank(errorResume)) { - errorResume = Boolean.TRUE.toString(); + errorResume = Boolean.FALSE.toString(); } if (StrUtil.isBlank(any)){ any = Boolean.FALSE.toString(); @@ -175,6 +175,9 @@ public abstract class JsonFlowParser extends FlowParser { } else if (hasChain(flowJsonObjectList, realItem.getId())) { Chain chain = FlowBus.getChain(realItem.getId()); node.setCondNode(chain.getChainName(), chain); + } else{ + String errorMsg = StrUtil.format("executable node[{}] is not found!", realItem.getId()); + throw new ExecutableItemNotFoundException(errorMsg); } } } @@ -186,7 +189,7 @@ public abstract class JsonFlowParser extends FlowParser { throw new ExecutableItemNotFoundException(errorMsg); } } - condition.setErrorResume(errorResume.equals(Boolean.TRUE.toString())); + condition.setErrorResume(Boolean.parseBoolean(errorResume)); condition.setGroup(group); condition.setAny(any.equals(Boolean.TRUE.toString())); condition.setConditionType(condType); diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/XmlFlowParser.java b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/XmlFlowParser.java index 804b7cc7d..b29c08105 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/XmlFlowParser.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/XmlFlowParser.java @@ -144,7 +144,7 @@ public abstract class XmlFlowParser extends FlowParser { group = LocalDefaultFlowConstant.DEFAULT; } if (StrUtil.isBlank(errorResume)) { - errorResume = Boolean.TRUE.toString(); + errorResume = Boolean.FALSE.toString(); } if (StrUtil.isBlank(any)){ any = Boolean.FALSE.toString(); @@ -174,6 +174,9 @@ public abstract class XmlFlowParser extends FlowParser { } else if (hasChain(documentList, realItem.getId())) { Chain chain = FlowBus.getChain(realItem.getId()); node.setCondNode(chain.getChainName(), chain); + } else{ + String errorMsg = StrUtil.format("executable node[{}] is not found!", realItem.getId()); + throw new ExecutableItemNotFoundException(errorMsg); } } } @@ -185,7 +188,7 @@ public abstract class XmlFlowParser extends FlowParser { throw new ExecutableItemNotFoundException(errorMsg); } } - condition.setErrorResume(errorResume.equals(Boolean.TRUE.toString())); + condition.setErrorResume(Boolean.parseBoolean(errorResume)); condition.setGroup(group); condition.setAny(any.equals(Boolean.TRUE.toString())); condition.setConditionType(condE.getName()); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java index a0e8346bd..b6cc97ca4 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java @@ -44,6 +44,7 @@ public class AsyncNodeSpringbootTest extends BaseTest { System.out.println(response.getSlot().getExecuteStepStr()); } + //这个和test1有点类似,只不过进一步验证了步骤 @Test public void testAsyncFlow2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); @@ -53,6 +54,21 @@ public class AsyncNodeSpringbootTest extends BaseTest { ).contains(response.getSlot().getExecuteStepStr())); } + //测试errorResume,默认的errorResume为false,这里测试默认的 + @Test + public void testAsyncFlow3_1() { + LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request"); + Assert.assertFalse(response.isSuccess()); + Assert.assertEquals(response.getSlot().getException().getClass(), TestException.class); + } + + //测试errorResume,默认的errorResume为false,这里设置为true + @Test + public void testAsyncFlow3_2() { + LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request"); + Assert.assertTrue(response.isSuccess()); + } + //相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了不抛错 @Test public void testAsyncFlow4() { diff --git a/liteflow-testcase-springboot/src/test/resources/asyncNode/flow.xml b/liteflow-testcase-springboot/src/test/resources/asyncNode/flow.xml index 41d31b35f..e81546bb6 100644 --- a/liteflow-testcase-springboot/src/test/resources/asyncNode/flow.xml +++ b/liteflow-testcase-springboot/src/test/resources/asyncNode/flow.xml @@ -11,7 +11,17 @@ - + + + + + + + + + + + diff --git a/liteflow-testcase-springboot/src/test/resources/whenTimeOut/flow.xml b/liteflow-testcase-springboot/src/test/resources/whenTimeOut/flow.xml index 657f64cc3..70e2312d7 100644 --- a/liteflow-testcase-springboot/src/test/resources/whenTimeOut/flow.xml +++ b/liteflow-testcase-springboot/src/test/resources/whenTimeOut/flow.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file