Does BeanShell/JSR23 Processor supports Generics(Java) in Jmeter

297 views
Skip to first unread message

Anshu Srivastava

unread,
Sep 6, 2016, 10:17:24 AM9/6/16
to JMeter Forum
Below is the code i am trying to execute in Beanshell/JSR223 PreProcessor:

 line 12-         String cookie = vars.get("cookie");
 line 13-    int i = cookie.lastIndexOf('.');
 line 14-    String withoutSignature = cookie.substring(0, i + 1);
 line 15-     Jwt<Header, Claims> untrusted = Jwts.parser().parseClaimsJwt(withoutSignature); // This line does not get executed.

Below is the exception :

2016/09/06 19:44:59 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval In file: inline evaluation of: ``import io.jsonwebtoken.Jwt; import io.jsonwebtoken.JwtBuilder; import io.jsonweb . . . '' Encountered "," at line 15, column 23.
 
2016/09/06 19:44:59 WARN  - jmeter.extractor.BeanShellPostProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval In file: inline evaluation of: ``import io.jsonwebtoken.Jwt; import io.jsonwebtoken.JwtBuilder; import io.jsonweb . . . '' Encountered "," at line 15, column 23.
 

DT

unread,
Sep 7, 2016, 12:39:28 AM9/7/16
to JMeter Forum
Beanshell does not support generics so you either have to remove them like:

Jwt<Header, Claims> untrusted = Jwts.parser().parseClaimsJwt(withoutSignature);

or switch to JSR223 Sampler and Groovy language combination - it's more Java-compliant. Moreover, your test script performance will ramp up as well-developed Groovy scripts can be compiled into bytecode. See Beanshell vs JSR223 vs Java JMeter Scripting: The Performance-Off You've Been Waiting For! article for benchmarks and scripting best practices


Anshu Srivastava

unread,
Sep 7, 2016, 2:35:33 AM9/7/16
to JMeter Forum
Thanks a lot for the info DT.

Vincent Daburon

unread,
Sep 7, 2016, 4:09:43 AM9/7/16
to JMeter Forum
Hi,
Java BeanShell is some times different than classic Java

You need to remove the type for object like array, list ... because Java BeanShell auto map the type.
So you have to declare :
 line 12-         String cookie = vars.get("cookie");
 line 13-    int i = cookie.lastIndexOf('.');
 line 14-    String withoutSignature = cookie.substring(0, i + 1);
 line 15-     untrusted = Jwts.parser().parseClaimsJwt(withoutSignature); // This line does not get executed.

Regards.
Vincent D.
Reply all
Reply to author
Forward
0 new messages