enhancement #I90IRR 设置超时maxWaitSenconds之后,超时的组件仍旧执行会报出NPE的问题

This commit is contained in:
everywhere.z
2024-02-01 19:22:37 +08:00
parent a79af2ba29
commit 2d9c357d8f
3 changed files with 34 additions and 0 deletions

View File

@@ -182,6 +182,16 @@ public class MaxWaitSecondsELSpringbootTest extends BaseTest {
assertNotTimeout("chain2");
}
// 测试超时情况下组件还在运行的场景是否会报错
@Test
public void testChain3() {
DefaultContext context = new DefaultContext();
context.setData("test", "123");
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg", context);
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals(TimeoutException.class, response.getCause().getClass());
}
private void assertTimeout(String chainId) {
LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg");
Assertions.assertFalse(response.isSuccess());

View File

@@ -0,0 +1,20 @@
package com.yomahub.liteflow.test.maxWaitSeconds.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.slot.DefaultContext;
@LiteflowComponent("e")
public class ECmp extends NodeComponent {
@Override
public void process() throws Exception{
DefaultContext context = this.getFirstContextBean();
for (int i = 0; i < 10; i++) {
String str = context.getData("test");
System.out.println(str);
Thread.sleep(1000);
}
System.out.println("ECmp executed!");
}
}

View File

@@ -107,4 +107,8 @@
<!-- 不超时 -->
testChain.maxWaitSeconds(3);
</chain>
<chain name="chain3">
THEN(a, b, e).maxWaitSeconds(8);
</chain>
</flow>