diff --git a/backend/src/main/java/io/metersphere/performance/service/LoadTestVumEvent.java b/backend/src/main/java/io/metersphere/performance/service/LoadTestVumEvent.java index e208de9b78..0e401c0c92 100644 --- a/backend/src/main/java/io/metersphere/performance/service/LoadTestVumEvent.java +++ b/backend/src/main/java/io/metersphere/performance/service/LoadTestVumEvent.java @@ -7,10 +7,12 @@ import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper; import io.metersphere.commons.constants.PerformanceTestStatus; import io.metersphere.commons.constants.ReportKeys; import io.metersphere.commons.consumer.LoadTestFinishEvent; +import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.LogUtil; import io.metersphere.performance.base.VumProcessedStatus; import io.metersphere.service.QuotaService; +import org.apache.commons.lang3.StringUtils; import org.redisson.api.RLock; import org.redisson.api.RedissonClient; import org.springframework.stereotype.Component; @@ -55,6 +57,9 @@ public class LoadTestVumEvent implements LoadTestFinishEvent { QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class); String projectId = report.getProjectId(); Project project = projectMapper.selectByPrimaryKey(projectId); + if (project == null || StringUtils.isBlank(project.getWorkspaceId())) { + MSException.throwException("project is null or workspace_id of project is null. project id: " + projectId); + } RLock lock = redissonClient.getLock(project.getWorkspaceId()); if (quotaService != null) { try { diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java index ab35b89b7c..bfe07d5e95 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java @@ -172,6 +172,9 @@ public class PerformanceReportService { QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class); String projectId = report.getProjectId(); Project project = projectMapper.selectByPrimaryKey(projectId); + if (project == null || StringUtils.isBlank(project.getWorkspaceId())) { + MSException.throwException("project is null or workspace_id of project is null. project id: " + projectId); + } RLock lock = redissonClient.getLock(project.getWorkspaceId()); if (quotaService != null) { try { diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index 822672213c..9fc6c7f2dd 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -540,6 +540,9 @@ public class PerformanceTestService { quotaService.checkLoadTestQuota(checkRequest, false); String projectId = testReport.getProjectId(); Project project = projectMapper.selectByPrimaryKey(projectId); + if (project == null || StringUtils.isBlank(project.getWorkspaceId())) { + MSException.throwException("project is null or workspace_id of project is null. project id: " + projectId); + } RLock lock = redissonClient.getLock(project.getWorkspaceId()); try { lock.lock();