From 61d58d8ce7249c4249b0942d26f7925b463b2361 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 15 Oct 2024 14:07:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E8=B0=83=E6=95=B4=E9=AA=8C=E8=AF=81=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/service/ApiExecuteService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 1c2ecec356..629c76a6f0 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 @@ -241,6 +241,9 @@ public class ApiExecuteService { EngineFactory.runApi(taskRequest, testResourceDTO); } } else { + if (CollectionUtils.isEmpty(testResourcePoolDTO.getTestResourceReturnDTO().getNodesList())) { + throw new MSException(ApiResultCode.EXECUTE_RESOURCE_POOL_NOT_CONFIG); + } TestResourceNodeDTO testResourceNodeDTO = getNextExecuteNode(testResourcePoolDTO); if (!ApiExecuteRunMode.isDebug(taskInfo.getRunMode())) { updateTaskItemNodeInfo(taskItem, testResourcePoolDTO, testResourceNodeDTO, execTaskItemMapper); @@ -320,6 +323,9 @@ public class ApiExecuteService { } else { // 将任务按资源池的数量拆分 List nodesList = testResourcePool.getTestResourceReturnDTO().getNodesList(); + if (CollectionUtils.isEmpty(nodesList)) { + throw new MSException(ApiResultCode.EXECUTE_RESOURCE_POOL_NOT_CONFIG); + } List distributeTasks = new ArrayList<>(nodesList.size()); for (int i = 0; i < taskRequest.getTaskItems().size(); i++) { TaskBatchRequestDTO distributeTask; @@ -412,7 +418,7 @@ public class ApiExecuteService { } TestResourcePoolReturnDTO resourcePool = getAvailableResourcePoolDTO(projectId, poolId); - if (resourcePool == null || CollectionUtils.isEmpty(resourcePool.getTestResourceReturnDTO().getNodesList())) { + if (resourcePool == null) { throw new MSException(ApiResultCode.EXECUTE_RESOURCE_POOL_NOT_CONFIG); } return resourcePool;