浏览代码

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

everywhere.z 1 年之前
父节点
当前提交
2d9c357d8f

+ 10 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELSpringbootTest.java

@@ -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());

+ 20 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/cmp/ECmp.java

@@ -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!");
+    }
+}

+ 4 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/maxWaitSeconds/flow.el.xml

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