mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 12:12:08 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -154,8 +154,13 @@ public class Node implements Executable, Cloneable, Rollbackable{
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
// 如果组件覆盖了isEnd方法,或者在在逻辑中主要调用了setEnd(true)的话,流程就会立马结束
|
||||
if (instance.isEnd()) {
|
||||
String errorInfo = StrUtil.format("[{}] lead the chain to end", instance.getDisplayName());
|
||||
throw new ChainEndException(errorInfo);
|
||||
}
|
||||
// 如果组件覆盖了isContinueOnError方法,返回为true,那即便出了异常,也会继续流程
|
||||
if (instance.isContinueOnError()) {
|
||||
else if (instance.isContinueOnError()) {
|
||||
String errorMsg = StrUtil.format("component[{}] cause error,but flow is still go on", id);
|
||||
LOG.error(errorMsg);
|
||||
}
|
||||
|
||||
@@ -83,4 +83,12 @@ public class FlowExecutorTest extends BaseTest {
|
||||
Assertions.assertEquals("g", response.getExecuteStepStr());
|
||||
}
|
||||
|
||||
// 测试setIsEnd如果为true,continueError也为true,那不应该continue了,并且都在同一个 cmp 中
|
||||
@Test
|
||||
public void testSetIsEnd3() throws Exception {
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain8", 10);
|
||||
Assertions.assertTrue(response.isSuccess());
|
||||
Assertions.assertEquals("i", response.getExecuteStepStr());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.yomahub.liteflow.test.component.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
public class ICmp extends NodeComponent {
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
System.out.println("process i");
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isContinueOnError() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnd() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.yomahub.liteflow.test.component.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
public class JCmp extends NodeComponent {
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
System.out.println("process j");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.yomahub.liteflow.test.component.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
public class KCmp extends NodeComponent {
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
System.out.println("process k");
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,9 @@
|
||||
<node id="f" class="com.yomahub.liteflow.test.component.cmp2.FSwitchCmp"/>
|
||||
<node id="g" class="com.yomahub.liteflow.test.component.cmp1.GCmp"/>
|
||||
<node id="h" class="com.yomahub.liteflow.test.component.cmp1.HCmp"/>
|
||||
<node id="i" class="com.yomahub.liteflow.test.component.cmp1.ICmp"/>
|
||||
<node id="j" class="com.yomahub.liteflow.test.component.cmp1.JCmp"/>
|
||||
<node id="k" class="com.yomahub.liteflow.test.component.cmp1.KCmp"/>
|
||||
</nodes>
|
||||
|
||||
<chain name="chain1">
|
||||
@@ -38,4 +41,8 @@
|
||||
<chain name="chain7">
|
||||
THEN(g, h);
|
||||
</chain>
|
||||
|
||||
<chain name="chain8">
|
||||
THEN(i, j, k);
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user