From 34a0f005f37088ed51362f28738b6e96778d9dd0 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 28 Sep 2020 10:48:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=8F=90=E5=8F=96=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/jmeter/APIBackendListenerClient.java | 6 +++--- .../src/main/java/io/metersphere/api/jmeter/JMeterVars.java | 4 ++-- .../src/business/components/api/test/model/ScenarioModel.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) 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)); }