From da869a97d213e319f308814478e222b134dc4298 Mon Sep 17 00:00:00 2001 From: "Melissa.Lu" Date: Fri, 3 Dec 2021 13:43:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=8E=8B=E6=B5=8B?= =?UTF-8?q?=E4=B8=AD=E5=9B=A0=E4=B8=BA=E7=BD=91=E7=BB=9C=E5=8E=9F=E5=9B=A0?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84jmx=E4=B8=8B=E8=BD=BD=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit beafdc1b3164fab238e0244e693535cbb27646e7) --- .../performance/service/JmeterFileService.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/io/metersphere/performance/service/JmeterFileService.java b/backend/src/main/java/io/metersphere/performance/service/JmeterFileService.java index 95019dfc56..292f6dd410 100644 --- a/backend/src/main/java/io/metersphere/performance/service/JmeterFileService.java +++ b/backend/src/main/java/io/metersphere/performance/service/JmeterFileService.java @@ -20,6 +20,8 @@ import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import static org.python.modules.time.Time.sleep; + @Service @Transactional(rollbackFor = Exception.class) public class JmeterFileService { @@ -30,7 +32,16 @@ public class JmeterFileService { public byte[] downloadZip(String reportId, double[] ratios, int resourceIndex) { try { - LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); + LoadTestReportWithBLOBs loadTestReport = null; + double waitingSeconds = 0; + while (loadTestReport == null) { + if (waitingSeconds > 12000) { + break; + } + sleep(0.3); + waitingSeconds += 0.3; + loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); + } if (loadTestReport == null) { MSException.throwException("测试报告不存在或还没产生"); }