diff --git a/backend/src/main/java/io/metersphere/performance/engine/EngineContext.java b/backend/src/main/java/io/metersphere/performance/engine/EngineContext.java index 70586532b4..2a95d9f116 100644 --- a/backend/src/main/java/io/metersphere/performance/engine/EngineContext.java +++ b/backend/src/main/java/io/metersphere/performance/engine/EngineContext.java @@ -16,6 +16,7 @@ public class EngineContext { private Map properties = new HashMap<>(); private Map testResourceFiles = new HashMap<>(); private Map splitFlag = new HashMap<>(); + private boolean checkBackendListener; public String getTestId() { return testId; @@ -117,4 +118,12 @@ public class EngineContext { public void setSplitFlag(Map splitFlag) { this.splitFlag = splitFlag; } + + public boolean isCheckBackendListener() { + return checkBackendListener; + } + + public void setCheckBackendListener(boolean checkBackendListener) { + this.checkBackendListener = checkBackendListener; + } } diff --git a/backend/src/main/java/io/metersphere/performance/parse/xml/reader/JmeterDocumentParser.java b/backend/src/main/java/io/metersphere/performance/parse/xml/reader/JmeterDocumentParser.java index f331e1dcd8..6d4d13774d 100644 --- a/backend/src/main/java/io/metersphere/performance/parse/xml/reader/JmeterDocumentParser.java +++ b/backend/src/main/java/io/metersphere/performance/parse/xml/reader/JmeterDocumentParser.java @@ -612,6 +612,10 @@ public class JmeterDocumentParser implements EngineSourceParser { if (checkLicense() && !BooleanUtils.toBoolean(resourcePool.getBackendListener())) { return; } + // 已经添加过不再重复添加 + if (context.isCheckBackendListener()) { + return; + } Element listenerParent = getNextSibling(element); @@ -632,6 +636,8 @@ public class JmeterDocumentParser implements EngineSourceParser { backendListener.addAttribute("enabled", "true"); listenerParent.addElement(HASH_TREE_ELEMENT); + // 标记已经添加上 + context.setCheckBackendListener(true); } private boolean checkLicense() {