vlsi commented on issue #6451:
URL: https://github.com/apache/jmeter/issues/6451#issuecomment-5011462812
This is working as designed, though the boundary isn't documented well
enough.
`CSVDataSet` is a `TestBean`. TestBeans keep their configuration in the test
element's property map, and their Java fields are a per-thread runtime view
that `TestBeanHelper.prepare()` populates when the test starts. That's why the
fields are `transient`: they aren't part of the element's persisted state.
`SaveService.loadTree()` restores the property map, so
`getPropertyAsString("filename")` returns your value, while `getFilename()`
reads the field that `prepare()` hasn't populated yet.
For inspecting a loaded plan, read the property directly:
```java
String filename = csvDataSet.getPropertyAsString("filename");
```
If you need several getters on the same element, populate the bean once and
use the getters as usual:
```java
TestBeanHelper.prepare(csvDataSet);
String filename = csvDataSet.getFilename();
```
Note that `prepare()` mutates the element, so the first form is preferable
for read-only inspection.
One caveat for your use case: a filename can contain functions or variables
(`${__P(csvdir)}/data.csv`, `${dataFile}`). Those resolve only while a test
runs, so outside a running test you get the raw expression either way. If
you're collecting dataset files for packaging or validation, you'll need to
decide how to handle plans that compute the path at runtime.
Unrelated to the bug, `SearchByClass` will save you the manual recursion:
```java
SearchByClass<CSVDataSet> search = new SearchByClass<>(CSVDataSet.class);
hashTree.traverse(search);
for (CSVDataSet ds : search.getSearchResults()) {
// ...
}
```
The same applies to every TestBean element, not just `CSVDataSet` — JSR223
elements, `ConstantThroughputTimer`, and others behave identically.
#6726 explores making `CSVDataSet` store its configuration in the property
map directly, which would make the getters valid at any point. That's a design
change affecting the TestBean contract across ~60 elements, so it's being
discussed there rather than treated as a fix for this issue.
Closing as works-as-designed. Happy to reopen if the property-based access
doesn't cover your case.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]