diff --git a/backend/src/main/java/io/metersphere/api/jmeter/LocalRunner.java b/backend/src/main/java/io/metersphere/api/jmeter/LocalRunner.java index 9c5a42800f..b00915af00 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/LocalRunner.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/LocalRunner.java @@ -1,6 +1,7 @@ package io.metersphere.api.jmeter; import io.metersphere.commons.utils.LogUtil; +import org.apache.commons.lang3.StringUtils; import org.apache.jmeter.engine.JMeterEngineException; import org.apache.jmeter.engine.StandardJMeterEngine; import org.apache.jorphan.collections.HashTree; @@ -20,7 +21,9 @@ public class LocalRunner { engine.configure(jmxTree); try { engine.runTest(); - MessageCache.runningEngine.put(report, engine); + if (StringUtils.isNotEmpty(report)) { + MessageCache.runningEngine.put(report, engine); + } } catch (JMeterEngineException e) { engine.stopTest(true); } @@ -29,7 +32,7 @@ public class LocalRunner { public void stop(String report) { try { StandardJMeterEngine engine = MessageCache.runningEngine.get(report); - if (engine != null) { + if (engine != null && StringUtils.isNotEmpty(report)) { engine.stopTest(); MessageCache.runningEngine.remove(report); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java index 1971ec0367..8dbaabbf84 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java @@ -480,9 +480,9 @@ public class TestPlanApiCaseService { ApiDefinitionExecResult report = addResult(request, key, APITestStatus.Running.name(), batchMapper); modeDataDTO.setApiCaseId(report.getId()); if (request.getConfig() != null && StringUtils.isNotEmpty(request.getConfig().getResourcePoolId())) { - jMeterService.runTest(modeDataDTO.getTestId(), modeDataDTO.getApiCaseId(), ApiRunMode.API_PLAN.name(), null, request.getConfig()); + jMeterService.runTest(report.getId(), modeDataDTO.getApiCaseId(), ApiRunMode.API_PLAN.name(), null, request.getConfig()); } else { - jMeterService.runLocal(modeDataDTO.getTestId(), modeDataDTO.getHashTree(), TriggerMode.BATCH.name() , ApiRunMode.API_PLAN.name()); + jMeterService.runLocal(report.getId(), modeDataDTO.getHashTree(), TriggerMode.BATCH.name() , ApiRunMode.API_PLAN.name()); } } sqlSession.flushStatements();