From 7a1e44353a4b5fefe907581eb6829d5b78ea4f24 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Tue, 22 Jun 2021 10:39:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=A0=E9=99=A4=E6=B5=8B=E8=AF=95=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E5=86=8D=E5=88=A0=E9=99=A4=E6=8A=A5=E5=91=8A=E6=8A=A5?= =?UTF-8?q?=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 --- .../service/PerformanceReportService.java | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) 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 522ef8c427..ed388f7079 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java @@ -96,24 +96,26 @@ public class PerformanceReportService { LogUtil.info("Delete report started, report ID: %s" + reportId); - try { - final Engine engine = EngineFactory.createEngine(loadTest); - if (engine == null) { - MSException.throwException(String.format("Delete report fail. create engine fail,report ID:%s", reportId)); - } + if (loadTest != null) { + try { + final Engine engine = EngineFactory.createEngine(loadTest); + if (engine == null) { + MSException.throwException(String.format("Delete report fail. create engine fail,report ID:%s", reportId)); + } - String reportStatus = loadTestReport.getStatus(); - boolean isRunning = StringUtils.equals(reportStatus, PerformanceTestStatus.Running.name()); - boolean isStarting = StringUtils.equals(reportStatus, PerformanceTestStatus.Starting.name()); - boolean isError = StringUtils.equals(reportStatus, PerformanceTestStatus.Error.name()); - if (isRunning || isStarting || isError) { - LogUtil.info("Start stop engine, report status: %s" + reportStatus); - stopEngine(loadTest, engine); + String reportStatus = loadTestReport.getStatus(); + boolean isRunning = StringUtils.equals(reportStatus, PerformanceTestStatus.Running.name()); + boolean isStarting = StringUtils.equals(reportStatus, PerformanceTestStatus.Starting.name()); + boolean isError = StringUtils.equals(reportStatus, PerformanceTestStatus.Error.name()); + if (isRunning || isStarting || isError) { + LogUtil.info("Start stop engine, report status: %s" + reportStatus); + stopEngine(loadTest, engine); + } + } catch (Exception e) { + LogUtil.error(e.getMessage(), e); + loadTest.setStatus(PerformanceTestStatus.Saved.name()); + loadTestMapper.updateByPrimaryKeySelective(loadTest); } - } catch (Exception e) { - LogUtil.error(e.getMessage(), e); - loadTest.setStatus(PerformanceTestStatus.Saved.name()); - loadTestMapper.updateByPrimaryKeySelective(loadTest); } // delete load_test_report_result