diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/CatchCondition.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/CatchCondition.java index a56d17f54..48e8721a4 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/CatchCondition.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/CatchCondition.java @@ -28,15 +28,13 @@ public class CatchCondition extends Condition{ catchExecutable.execute(slotIndex); }catch (Exception e){ Executable doExecutable = this.getDoItem(); - if (ObjectUtil.isNull(doExecutable)){ - String errorInfo = StrUtil.format("[{}]:no catch do item find", slot.getRequestId()); - throw new CatchErrorException(errorInfo); + if (ObjectUtil.isNotNull(doExecutable)){ + doExecutable.setCurrChainId(this.getCurrChainId()); + doExecutable.execute(slotIndex); + //catch之后需要把exception给清除掉 + //正如同java的catch一样,异常自己处理了,属于正常流程了,整个流程状态应该是成功的 + DataBus.getSlot(slotIndex).removeException(); } - doExecutable.setCurrChainId(this.getCurrChainId()); - doExecutable.execute(slotIndex); - //catch之后需要把exception给清除掉 - //正如同java的catch一样,异常自己处理了,属于正常流程了,整个流程状态应该是成功的 - DataBus.getSlot(slotIndex).removeException(); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/catchcase/CatchELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/catchcase/CatchELSpringbootTest.java index ffe41767f..4841446e3 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/catchcase/CatchELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/catchcase/CatchELSpringbootTest.java @@ -42,4 +42,18 @@ public class CatchELSpringbootTest extends BaseTest { Assert.assertFalse(response.isSuccess()); Assert.assertEquals("a==>d", response.getExecuteStepStrWithoutTime()); } + + @Test + public void testCatch3() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + Assert.assertFalse(response.isSuccess()); + Assert.assertEquals("a", response.getExecuteStepStrWithoutTime()); + } + + @Test + public void testCatch4() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + Assert.assertFalse(response.isSuccess()); + Assert.assertEquals("LOOP_3==>a==>b==>a==>b==>a==>b", response.getExecuteStepStrWithoutTime()); + } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/catchcase/cmp/ECmp.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/catchcase/cmp/ECmp.java new file mode 100644 index 000000000..e7bf09947 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/catchcase/cmp/ECmp.java @@ -0,0 +1,21 @@ +/** + *
Title: liteflow
+ *Description: 轻量级的组件式流程框架
+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.catchcase.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("e") +public class ECmp extends NodeComponent { + + @Override + public void process() { + System.out.println("ECmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/catchcase/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/catchcase/flow.el.xml index 026ef934a..31017e0b8 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/catchcase/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/catchcase/flow.el.xml @@ -12,4 +12,18 @@ THEN(a,b) ).DO(d) + +