mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
bug #I4HQAA setIsEnd目前受isContinue的判断影响,还是会继续
This commit is contained in:
@@ -107,7 +107,7 @@ public class Node implements Executable,Cloneable{
|
||||
instance.setSlotIndex(slotIndex);
|
||||
Slot slot = DataBus.getSlot(slotIndex);
|
||||
|
||||
try{
|
||||
try {
|
||||
//判断是否可执行,所以isAccess经常作为一个组件进入的实际判断要素,用作检查slot里的参数的完备性
|
||||
if (instance.isAccess()) {
|
||||
|
||||
@@ -135,7 +135,7 @@ public class Node implements Executable,Cloneable{
|
||||
boolean flag = forExceptions.stream().anyMatch(clazz -> clazz.isAssignableFrom(e.getClass()));
|
||||
|
||||
//两种情况不重试,1)抛出异常不在指定异常范围内 2)已经重试次数大于等于配置次数
|
||||
if (!flag || i >= retryCount){
|
||||
if (!flag || i >= retryCount) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -144,12 +144,14 @@ public class Node implements Executable,Cloneable{
|
||||
|
||||
//如果组件覆盖了isEnd方法,或者在在逻辑中主要调用了setEnd(true)的话,流程就会立马结束
|
||||
if (instance.isEnd()) {
|
||||
String errorInfo = StrUtil.format("[{}]:component[{}] lead the chain to end",slot.getRequestId(),instance.getClass().getSimpleName());
|
||||
String errorInfo = StrUtil.format("[{}]:component[{}] lead the chain to end", slot.getRequestId(), instance.getClass().getSimpleName());
|
||||
throw new ChainEndException(errorInfo);
|
||||
}
|
||||
} else {
|
||||
LOG.info("[{}]:[X]skip component[{}] execution",slot.getRequestId(),instance.getClass().getSimpleName());
|
||||
LOG.info("[{}]:[X]skip component[{}] execution", slot.getRequestId(), instance.getClass().getSimpleName());
|
||||
}
|
||||
} catch (ChainEndException e){
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
//如果组件覆盖了isContinueOnError方法,返回为true,那即便出了异常,也会继续流程
|
||||
if (instance.isContinueOnError()) {
|
||||
|
||||
@@ -72,7 +72,7 @@ public class FlowExecutorTest extends BaseTest {
|
||||
|
||||
//setIsEnd方法的功能点测试
|
||||
@Test
|
||||
public void testSetIsEnd() throws Exception {
|
||||
public void testSetIsEnd1() throws Exception {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain5", 10);
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("e",response.getSlot().printStep());
|
||||
@@ -85,4 +85,12 @@ public class FlowExecutorTest extends BaseTest {
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
//测试setIsEnd如果为true,continueError也为true,那不应该continue了
|
||||
@Test
|
||||
public void testSetIsEnd2() throws Exception {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain7", 10);
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("g",response.getSlot().printStep());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.component.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("g")
|
||||
public class GCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("GCmp executed!");
|
||||
this.setIsEnd(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isContinueOnError() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.component.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("h")
|
||||
public class HCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("HCmp executed!");
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1 @@
|
||||
liteflow.rule-source=component/flow.xml
|
||||
liteflow.retry_count=3
|
||||
liteflow.rule-source=component/flow.xml
|
||||
@@ -23,4 +23,8 @@
|
||||
<chain name="chain6">
|
||||
<then value="f(d | c | b)" />
|
||||
</chain>
|
||||
|
||||
<chain name="chain7">
|
||||
<then value="g,h"/>
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user