From f0acc7c39289ef09fabf200581235a12af0a58d1 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 13 Jan 2021 13:43:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=82=E6=95=B0=E6=8F=90=E5=8F=96=20?= =?UTF-8?q?=E7=A9=BA=E6=8C=87=E9=92=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/jmeter/APIBackendListenerClient.java | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 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 6a9b1d880e..c81e893221 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java @@ -304,21 +304,13 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl responseResult.setResponseSize(result.getResponseData().length); responseResult.setResponseTime(result.getTime()); responseResult.setResponseMessage(result.getResponseMessage()); - - if (JMeterVars.get(result.hashCode()) != null) { - List vars = new LinkedList<>(); - JMeterVars.get(result.hashCode()).entrySet().parallelStream().reduce(vars, (first, second) -> { - first.add(second.getKey() + ":" + second.getValue()); - return first; - }, (first, second) -> { - if (first == second) { - return first; - } - first.addAll(second); - return first; - }); - if (CollectionUtils.isNotEmpty(vars)) { - responseResult.setVars(StringUtils.join(vars, "\n")); + if (JMeterVars.get(result.hashCode()) != null && CollectionUtils.isNotEmpty(JMeterVars.get(result.hashCode()).entrySet())) { + StringBuilder builder = new StringBuilder(); + for (Map.Entry entry : JMeterVars.get(result.hashCode()).entrySet()) { + builder.append(entry.getKey()).append(":").append(entry.getValue()).append("\n"); + } + if (StringUtils.isNotEmpty(builder)) { + responseResult.setVars(builder.toString()); } JMeterVars.remove(result.hashCode()); }