我正在使用最新的JMeter 4并尝试使用basic
jexl syntax
在中声明局部变量的
jexl function
可以使用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);)}