linvaux opened a new issue, #6451: URL: https://github.com/apache/jmeter/issues/6451
### Expected behavior When parsing a .jmx file using JMeter's SaveService.loadTree, the getFilename() method of org.apache.jmeter.config.CSVDataSet returns null despite the fact that the filename property is correctly set and visible within the internal propMap, the csvdataset file is: data.csv java code: ```java private List<String> findDatasetFiles(HashTree hashTree) { List<String> datasetFiles = new ArrayList<>(); if (hashTree == null) { return datasetFiles; } for (Object item : hashTree.keySet()) { if (item instanceof org.apache.jmeter.config.CSVDataSet csvDataSet) { String filename = csvDataSet.getFilename(); if (StringUtils.isNotBlank(filename)) { datasetFiles.add(filename); } } // 递归搜索子树 HashTree subTree = hashTree.get(item); if (subTree != null) { datasetFiles.addAll(findDatasetFiles(subTree)); } } return datasetFiles; } ``` jxm: ```xml <?xml version="1.0" encoding="UTF-8"?> <jmeterTestPlan version="1.2" properties="5.0" jmeter="5.6.3"> <hashTree> <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="测试计划"> <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="用户定义的变量"> <collectionProp name="Arguments.arguments"/> </elementProp> </TestPlan> <hashTree> <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="测试线程组"> <intProp name="ThreadGroup.num_threads">1</intProp> <intProp name="ThreadGroup.ramp_time">1</intProp> <boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp> <stringProp name="ThreadGroup.on_sample_error">continue</stringProp> <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="循环控制器"> <stringProp name="LoopController.loops">1</stringProp> <boolProp name="LoopController.continue_forever">false</boolProp> </elementProp> </ThreadGroup> <hashTree> <CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="CSV 数据文件设置"> <stringProp name="delimiter">,</stringProp> <stringProp name="fileEncoding">UTF-8</stringProp> <stringProp name="filename">data.csv</stringProp> <boolProp name="ignoreFirstLine">false</boolProp> <boolProp name="quotedData">false</boolProp> <boolProp name="recycle">true</boolProp> <stringProp name="shareMode">shareMode.all</stringProp> <boolProp name="stopThread">false</boolProp> <stringProp name="variableNames"></stringProp> </CSVDataSet> <hashTree/> </hashTree> </hashTree> </hashTree> </jmeterTestPlan> ``` ### Actual behavior I got a empty list, but this code could get filename: ```java private List<String> findDatasetFiles(HashTree hashTree) { List<String> datasetFiles = new ArrayList<>(); if (hashTree == null) { return datasetFiles; } for (Object item : hashTree.keySet()) { log.debug("Found config element: {}", item.getClass().getName()); if (item instanceof org.apache.jmeter.config.CSVDataSet csvDataSet) { JMeterProperty filenameProp = csvDataSet.getPropertyOrNull("filename"); if (filenameProp != null) { log.debug("Found CSVDataSet: {}", filenameProp.getStringValue()); datasetFiles.add(filenameProp.getStringValue()); } } // 递归查找子树 HashTree subTree = hashTree.get(item); if (subTree != null) { datasetFiles.addAll(findDatasetFiles(subTree)); } } return datasetFiles; } ``` ### Steps to reproduce the problem - Create a simple JMeter test plan containing at least one ThreadGroup with a CSVDataSet. - Set a valid filename for the CSVDataSet. - Save the test plan as a .jmx file. - Use the following code snippet to load and parse the .jmx file: ```java SaveService.loadProperties(); HashTree hashTree = SaveService.loadTree(new File(savedFileName)); findDatasetFiles(HashTree hashTree); ``` ### JMeter Version 5.6.3 ### Java Version jdk21 ### OS Version macOS Sequola 15.4.1 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@jmeter.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org