我正在使用最新的 JMeter 4 并尝试使用基本的jexl 语法在jexl 函数中声明局部变量
局部变量 可以使用 var 关键字定义;它们的识别规则与上下文变量相同。基本声明:var x;
所以在 JMeter 我试过了
${__jexl2(var x;)}
并成功,但使用${__jexl3(var x;)}
它会引发解析器异常:
2018-04-25 14:18:16,451 ERROR o.a.j.f.Jexl3Function: An error occurred while evaluating the expression "var a;"
org.apache.commons.jexl3.JexlException$Parsing: @1:1 parsing error in 'var'
at org.apache.commons.jexl3.JexlEngine.createExpression(JexlEngine.java:304) ~[commons-jexl3-3.1.jar:3.1]
at org.apache.jmeter.functions.Jexl3Function.execute(Jexl3Function.java:94) [ApacheJMeter_functions.jar:4.0 r1823414]
at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:137) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:112) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:101) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.testelement.AbstractTestElement.getPropertyAsString(AbstractTestElement.java:281) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.testelement.AbstractTestElement.getName(AbstractTestElement.java:165) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.sampler.DebugSampler.sample(DebugSampler.java:56) [ApacheJMeter_components.jar:4.0 r1823414]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:490) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:416) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:250) [ApacheJMeter_core.jar:4.0 r1823414]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_25]
是 JMeter 问题还是 jexl3 问题,还是我遗漏了什么?
编辑
除了无法解析 var 之外,它还无法解析;
,这是一个使用 jexl2 的工作示例,但使用 jexl3 失败:
${__jexl3(abc=new("java.util.ArrayList"\, 1);)}