From 30a537c376b0017de61404c5a7d39f233cf3df29 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 19 Apr 2023 11:59:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B2=A1=E6=9C=89=E5=BC=80=E5=90=AFui?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=9A=84=E6=97=B6=E5=80=99=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E7=82=B9=E5=87=BB=E5=85=A8=E9=83=A8=E5=81=9C?= =?UTF-8?q?=E6=AD=A2=E4=BC=9A=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1025606 --user=宋天阳 【测试跟踪】github#23758,UI测试不开启的时候,在测试计划页面点击全部停止报错 https://www.tapd.cn/55049933/s/1364280 --- .../metersphere/task/service/TaskService.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/task/service/TaskService.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/task/service/TaskService.java index 9b14e05a98..9852f982b3 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/task/service/TaskService.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/task/service/TaskService.java @@ -19,12 +19,12 @@ import io.metersphere.task.dto.TaskCenterDTO; import io.metersphere.task.dto.TaskCenterRequest; import io.metersphere.task.dto.TaskRequestDTO; import io.metersphere.task.dto.TaskStatisticsDTO; +import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import jakarta.annotation.Resource; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -130,17 +130,31 @@ public class TaskService { } public void stop(List reportIds) { + + if (CollectionUtils.isNotEmpty(reportIds)) { // 任务中心单条停止/全部停止 Map taskRequestMap = reportIds.stream().collect(Collectors.toMap(TaskRequestDTO::getType, taskRequest -> taskRequest)); if (taskRequestMap.containsKey(API) || taskRequestMap.containsKey(SCENARIO)) { - microService.postForData(MicroServiceName.API_TEST, "/api/automation/stop/batch", reportIds); + try { + microService.postForData(MicroServiceName.API_TEST, "/api/automation/stop/batch", reportIds); + } catch (Exception e) { + LogUtil.error("接口测试批量关闭失败!", e); + } } if (taskRequestMap.containsKey(PERF)) { - microService.postForData(MicroServiceName.PERFORMANCE_TEST, "/performance/stop/batch", taskRequestMap.get(PERF)); + try { + microService.postForData(MicroServiceName.PERFORMANCE_TEST, "/performance/stop/batch", taskRequestMap.get(PERF)); + } catch (Exception e) { + LogUtil.error("性能测试批量关闭失败!", e); + } } if (taskRequestMap.containsKey(UI)) { - microService.postForData(MicroServiceName.UI_TEST, "/ui/automation/stop/batch", reportIds); + try { + microService.postForData(MicroServiceName.UI_TEST, "/ui/automation/stop/batch", reportIds); + } catch (Exception e) { + LogUtil.error("ui测试批量关闭失败!", e); + } } } }