diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java index 6914302372..559c9f8a42 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java @@ -22,7 +22,6 @@ import io.metersphere.service.definition.ApiTestCaseService; import io.metersphere.service.plan.TestPlanApiCaseService; import lombok.Data; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.jmeter.config.Arguments; @@ -226,7 +225,7 @@ public class ParameterConfig extends MsParameter { } public void margeVariables(List variables, List transferVariables) { - if (CollectionUtils.isNotEmpty(transferVariables)) { + if (CollectionUtils.isNotEmpty(transferVariables) && CollectionUtils.isNotEmpty(variables)) { List constants = variables.stream() .filter(ScenarioVariable::isConstantValid).collect(Collectors.toList()); @@ -252,22 +251,4 @@ public class ParameterConfig extends MsParameter { }); } } - - public void margeParentVariables(List variables, MsTestElement parent) { - // 取出父级场景且父场景不是顶级场景 - MsScenario scenario = getScenario(parent); - if (scenario == null || BooleanUtils.isFalse(scenario.getMixEnable()) || CollectionUtils.isEmpty(scenario.getVariables())) { - return; - } - this.margeVariables(variables, scenario.getVariables()); - } - - private MsScenario getScenario(MsTestElement parent) { - if (parent != null && parent instanceof MsScenario) { - return parent.getParent() != null ? (MsScenario) parent : null; - } else if (parent != null && parent.getParent() != null) { - getScenario(parent.getParent()); - } - return null; - } } diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/shell/filter/ScriptFilter.java b/api-test/backend/src/main/java/io/metersphere/api/dto/shell/filter/ScriptFilter.java index 9f4c075c4d..7352ae7ab9 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/shell/filter/ScriptFilter.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/shell/filter/ScriptFilter.java @@ -3,10 +3,12 @@ package io.metersphere.api.dto.shell.filter; import io.metersphere.commons.constants.ElementConstants; import io.metersphere.commons.exception.MSException; import io.metersphere.plugin.core.utils.LogUtil; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import java.io.InputStream; +import java.nio.charset.Charset; import java.util.List; public class ScriptFilter { @@ -17,12 +19,14 @@ public class ScriptFilter { private static void blackList(StringBuffer buffer, String script, String path) { try { InputStream in = ScriptFilter.class.getResourceAsStream(path); - List bks = IOUtils.readLines(in); - bks.forEach(item -> { - if (script.contains(item) && script.indexOf(item) != -1) { - buffer.append(item).append(","); - } - }); + List bks = IOUtils.readLines(in, Charset.defaultCharset()); + if (CollectionUtils.isNotEmpty(bks)) { + bks.forEach(item -> { + if (script.contains(item) && script.indexOf(item) != -1) { + buffer.append(item).append(","); + } + }); + } } catch (Exception ex) { LogUtil.error(ex.getMessage()); }