vlsi commented on issue #6165:
URL: https://github.com/apache/jmeter/issues/6165#issuecomment-1860158198
## Root cause
1) `ConstantThroughputTimer` implements TestStateListener as it wants to
reset state when the test begins
2) ConstantThroughputTimer is TestBean, so JMeter attempts computing all the
properties before calling `constantThroughputTimer.testStarted()`
As `vars.put("throughput", ...)` happens during the test only, JMeter can't
resolve throughput value for ConstantThroughputTimer, so it fails with NPE.
Unfortunately, it is quite common for elements to implement
`TestStateListener` and `TestBean` at the same time, so the issue might impact
many use cases.
At the same time, JMeter can't predict which properties would indeed be
needed for execution of `testStarted()`, so JMeter has to conservatively
compute all the variables.
## Workarounds
The workaround could be writing `vars.get("throughput")` in such a way so it
does not fail when `"throughput"` variable is missing (before the first
execution).
Another workaround could be using properties rather than variables. Of
course, properties are global across threads, however, it might be enough in
certain cases.
## Long-term solution
a) Add "variable declaration" block, so users could declare variables along
with their initial values
b) Avoid `implements TestBean, TestStateListener` pattern. The problematic
case is `testStarted()`, so it could be replaced with
`org.apache.jmeter.threads.JMeterContextService#getTestStartTime` and something
else to reset values once
--
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]