From ef258a4be201f0e411e13bf6ea8f104eb2a92504 Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Fri, 22 Nov 2024 17:55:06 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E5=8F=91=E9=80=81=E6=89=A7=E8=A1=8C=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=EF=BC=8C=E5=93=8D=E5=BA=94=E8=B6=85=E6=97=B6=E4=B8=8D=E9=87=8D?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1048936 --user=陈建星 [测试计划]github#34183多资源池节点执行测试计划会导致报告显示步骤重复多次及测试执行时间翻倍 https://www.tapd.cn/55049933/s/1615683 --- .../metersphere/api/service/ApiExecuteService.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiExecuteService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiExecuteService.java index 53519772f3..87b396786b 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiExecuteService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiExecuteService.java @@ -59,11 +59,13 @@ import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.client.HttpServerErrorException; +import org.springframework.web.client.ResourceAccessException; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.net.SocketTimeoutException; import java.util.*; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.TimeUnit; @@ -298,6 +300,11 @@ public class ApiExecuteService { } break; } catch (Exception e) { + if (e instanceof ResourceAccessException resourceAccessException + && resourceAccessException.getCause() instanceof SocketTimeoutException) { + // 响应超时,则视为成功,避免任务重复发送 + break; + } lastException = e; LogUtils.error(e); // 记录异常节点,重试 @@ -417,6 +424,12 @@ public class ApiExecuteService { } break; } catch (Exception e) { + if (e instanceof ResourceAccessException resourceAccessException + && resourceAccessException.getCause() instanceof SocketTimeoutException) { + // 响应超时,则视为成功,避免任务重复发送 + success = true; + break; + } invalidNodeSet.add(testResourceNode); LogUtils.error("发送批量任务到 {} 节点执行失败", endpoint); LogUtils.error(e);