mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 12:12:08 +08:00
bug #I6G0D5 NodeIfComponent 重写 isAccess 导致空指针报错
This commit is contained in:
@@ -28,6 +28,11 @@ public class ForCondition extends LoopCondition{
|
||||
throw new NoForNodeException(errorInfo);
|
||||
}
|
||||
|
||||
//先去判断isAccess方法,如果isAccess方法都返回false,整个FOR表达式不执行
|
||||
if (!this.getForNode().isAccess(slotIndex)){
|
||||
return;
|
||||
}
|
||||
|
||||
//执行forCount组件
|
||||
forNode.setCurrChainId(this.getCurrChainId());
|
||||
forNode.execute(slotIndex);
|
||||
|
||||
@@ -27,6 +27,11 @@ public class IfCondition extends Condition {
|
||||
@Override
|
||||
public void execute(Integer slotIndex) throws Exception {
|
||||
if (ListUtil.toList(NodeTypeEnum.IF, NodeTypeEnum.IF_SCRIPT).contains(getIfNode().getType())){
|
||||
//先去判断isAccess方法,如果isAccess方法都返回false,整个IF表达式不执行
|
||||
if (!this.getIfNode().isAccess(slotIndex)){
|
||||
return;
|
||||
}
|
||||
|
||||
//先执行IF节点
|
||||
this.getIfNode().setCurrChainId(this.getCurrChainId());
|
||||
this.getIfNode().execute(slotIndex);
|
||||
|
||||
@@ -24,6 +24,11 @@ public class IteratorCondition extends LoopCondition{
|
||||
throw new NoIteratorNodeException(errorInfo);
|
||||
}
|
||||
|
||||
//先去判断isAccess方法,如果isAccess方法都返回false,整个ITERATOR表达式不执行
|
||||
if (!this.getIteratorNode().isAccess(slotIndex)){
|
||||
return;
|
||||
}
|
||||
|
||||
//执行Iterator组件
|
||||
iteratorNode.setCurrChainId(this.getCurrChainId());
|
||||
iteratorNode.execute(slotIndex);
|
||||
|
||||
@@ -36,6 +36,11 @@ public class SwitchCondition extends Condition{
|
||||
@Override
|
||||
public void execute(Integer slotIndex) throws Exception {
|
||||
if (ListUtil.toList(NodeTypeEnum.SWITCH, NodeTypeEnum.SWITCH_SCRIPT).contains(this.getSwitchNode().getType())){
|
||||
//先去判断isAccess方法,如果isAccess方法都返回false,整个SWITCH表达式不执行
|
||||
if (!this.getSwitchNode().isAccess(slotIndex)){
|
||||
return;
|
||||
}
|
||||
|
||||
//先执行switch节点
|
||||
this.getSwitchNode().setCurrChainId(this.getCurrChainId());
|
||||
this.getSwitchNode().execute(slotIndex);
|
||||
|
||||
@@ -28,6 +28,11 @@ public class WhileCondition extends LoopCondition{
|
||||
throw new NoWhileNodeException(errorInfo);
|
||||
}
|
||||
|
||||
//先去判断isAccess方法,如果isAccess方法都返回false,整个WHILE表达式不执行
|
||||
if (!this.getWhileNode().isAccess(slotIndex)){
|
||||
return;
|
||||
}
|
||||
|
||||
//获得要循环的可执行对象
|
||||
Executable executableItem = this.getDoExecutor();
|
||||
|
||||
|
||||
@@ -84,4 +84,12 @@ public class IfELSpringbootTest extends BaseTest {
|
||||
Assert.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime());
|
||||
}
|
||||
|
||||
//IF节点中isAccess返回false,这个情况相当于IF整个表达式串没执行
|
||||
@Test
|
||||
public void testIf8() throws Exception{
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain8", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("c", response.getExecuteStepStrWithoutTime());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.ifelse.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeIfComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("x2")
|
||||
public class X2Cmp extends NodeIfComponent {
|
||||
@Override
|
||||
public boolean processIf() throws Exception {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccess() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -38,4 +38,8 @@
|
||||
.ELIF(x1.tag("false"), d)
|
||||
.ELSE(THEN(d, b, a));
|
||||
</chain>
|
||||
|
||||
<chain name="chain8">
|
||||
THEN(IF(x2, a, b), c);
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user