From a64294e86ebcd206efed101247163c5543143870 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 21 Jan 2021 15:42:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E8=BF=81=E7=A7=BB=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E6=8A=A5=E9=94=99=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/dto/scenario/Body.java | 17 +++++++++++------ .../service/HistoricalDataUpgradeService.java | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java b/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java index de555a7c9f..bbe7959c49 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java @@ -3,6 +3,7 @@ package io.metersphere.api.dto.scenario; import io.metersphere.api.dto.scenario.request.BodyFile; import io.metersphere.commons.json.JSONSchemaGenerator; import lombok.Data; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy; import org.apache.jmeter.protocol.http.util.HTTPFileArg; @@ -81,12 +82,16 @@ public class Body { private HTTPFileArg[] httpFileArgs(String requestId) { List list = new ArrayList<>(); - this.getKvs().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> { - setFileArg(list, keyValue.getFiles(), keyValue, requestId); - }); - this.getBinary().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> { - setFileArg(list, keyValue.getFiles(), keyValue, requestId); - }); + if (CollectionUtils.isNotEmpty(this.getKvs())) { + this.getKvs().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> { + setFileArg(list, keyValue.getFiles(), keyValue, requestId); + }); + } + if (CollectionUtils.isNotEmpty(this.getBinary())) { + this.getBinary().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> { + setFileArg(list, keyValue.getFiles(), keyValue, requestId); + }); + } return list.toArray(new HTTPFileArg[0]); } diff --git a/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java b/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java index 73518b5f92..03d565035c 100644 --- a/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java +++ b/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java @@ -114,6 +114,7 @@ public class HistoricalDataUpgradeService { } if (request1.getBody() != null && request1.getBody().isOldKV()) { request1.getBody().setType(Body.FORM_DATA); + request1.getBody().setBinary(new ArrayList<>()); } BeanUtils.copyBean(element, request1); ((MsHTTPSamplerProxy) element).setProtocol(RequestType.HTTP);