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 27c0502310..8ef0c6f2e2 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 @@ -73,8 +73,7 @@ public class JmeterDocumentParser implements EngineSourceParser { if (hashTree.elements().size() > 0) { final List childNodes = hashTree.elements(); - for (int i = 0; i < childNodes.size(); i++) { - Element ele = childNodes.get(i); + for (Element ele : childNodes) { if (nodeNameEquals(ele, HASH_TREE_ELEMENT)) { parseHashTree(ele); } else if (nodeNameEquals(ele, TEST_PLAN)) { @@ -611,6 +610,15 @@ public class JmeterDocumentParser implements EngineSourceParser { Element listenerParent = getNextSibling(element); + List childNodes = listenerParent.elements(); + for (Element item : childNodes) { + if (nodeNameEquals(item, BACKEND_LISTENER)) { + // 如果已经存在,不再添加 + removeChildren(item); + return; + } + } + // add class name Element backendListener = listenerParent.addElement(BACKEND_LISTENER); backendListener.addAttribute("guiclass", "BackendListenerGui");