diff --git a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java index 11082e3c36..fca208b0c5 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java @@ -154,10 +154,10 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl responseResult.setResponseTime(result.getTime()); responseResult.setResponseMessage(result.getResponseMessage()); - if (JMeterVars.variables != null && JMeterVars.variables.get(result.getThreadName()) != null) { - JMeterVars.variables.get(result.getThreadName()).remove("TESTSTART.MS"); //去除系统变量 + if (JMeterVars.variables != null && JMeterVars.variables.get(result.hashCode()) != null) { + JMeterVars.variables.get(result.hashCode()).remove("TESTSTART.MS"); //去除系统变量 List vars = new LinkedList<>(); - JMeterVars.variables.get(result.getThreadName()).entrySet().parallelStream().reduce(vars, (first, second) -> { + JMeterVars.variables.get(result.hashCode()).entrySet().parallelStream().reduce(vars, (first, second) -> { first.add(second.getKey() + ":" + second.getValue()); return first; }, (first, second) -> { diff --git a/backend/src/main/java/io/metersphere/api/jmeter/JMeterVars.java b/backend/src/main/java/io/metersphere/api/jmeter/JMeterVars.java index 8839acf52d..36e8d128e5 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/JMeterVars.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/JMeterVars.java @@ -10,9 +10,9 @@ import java.util.List; import java.util.Map; public class JMeterVars { - public static Map variables = new HashMap<>(); + public static Map variables = new HashMap<>(); - public static void addVars(String testId, JMeterVariables vars, String extract) { + public static void addVars(Integer testId, JMeterVariables vars, String extract) { JMeterVariables vs = new JMeterVariables(); if (!StringUtils.isEmpty(extract) && vars != null) { List extracts = Arrays.asList(extract.split(";")); diff --git a/frontend/src/business/components/api/test/model/ScenarioModel.js b/frontend/src/business/components/api/test/model/ScenarioModel.js index 23f25856e9..fd3cae3dd6 100644 --- a/frontend/src/business/components/api/test/model/ScenarioModel.js +++ b/frontend/src/business/components/api/test/model/ScenarioModel.js @@ -1225,7 +1225,7 @@ class JMXGenerator { vars.push(request.extract.xpath[i].variable); } } - request.jsr223PostProcessor.script += "\n" + "io.metersphere.api.jmeter.JMeterVars.addVars(org.apache.jmeter.threads.JMeterContextService.getContext().getThread().getThreadName(),vars," + "\"" + vars.join(";") + "\"" + ");" + request.jsr223PostProcessor.script += "\n" + "io.metersphere.api.jmeter.JMeterVars.addVars(prev.hashCode(),vars," + "\"" + vars.join(";") + "\"" + ");" sampler.put(new JSR223PostProcessor(name, request.jsr223PostProcessor)); }