New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BSF JavaScript Preprocessor cannot access sampler variable on first interation #2180
Comments
Thomas Johnson (migrated from Bugzilla): |
Sebb (migrated from Bugzilla): This appears to be due to a bug in either BSF or Rhino, not JMeter. It does not appear to be possible to define a script variable with a null value to Javascript using BSF. Furthermore, any variables which are defined after the null value will also be inaccessible. The null variable in this case is "prev", so a work-round is to ensure that there is at least one previous sample result. The JMeter code can be rearanged to define the "prev" variable last, but obviously that is also only a work-round. |
Thomas Johnson (migrated from Bugzilla): From the snippet below, a quick run of the test case shows that BSF Jexl handles the null "prev" object just fine. As BSF Jexl and JS get set up by the same code, it is most likely that the issue lies in or close to Rhino itself. -- Test Case output -- -- References -- |
Sebb (migrated from Bugzilla): I raised https://issues.apache.org/jira/browse/BSF-22 for the error. |
Sebb (migrated from Bugzilla): This is in the current nightlies (from r724447) if you want to try it out. |
Sebb (migrated from Bugzilla): |
Thomas Johnson (Bug 46359):
The BSF JavaScript Preprocessor is unable to access the Sampler variable in the first iteration, citing the following exception:
org.apache.bsf.BSFException: JavaScript Error: Internal Error: org.mozilla.javascript.EcmaError: ReferenceError: "sampler" is not defined.
Steps to Reproduce:
1-Create a Thread Group set to run for two or more iterations
2-Add a Sampler to the Thread Group (tested with an HTTP Sampler)
3-Add a BSF PreProcessor to the Sampler
4-Use javascript as the BSF Language
5-Enter a simple script that references the "sampler" variable. Tested with OUT.println("hello"); OUT.println(sampler);
6-Run
Expected Results:
Actual Results:
ipt Error: Internal Error: org.mozilla.javascript.EcmaError: ReferenceError: "sampler" is not defined.
Affects Versions:
Created attachment dynamic-forms.jmx: Test Case illustrating issue
dynamic-forms.jmx
Severity: normal
OS: Mac OS X 10.4
The text was updated successfully, but these errors were encountered: