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);