Jmeter Beanshell could not recognize Set <String>
I want to delete data in redis
before taking a sample to put the code in the Beanshell Preprocessor. But the code doesn't work, just like Beanshell can't recognize Set, part of my code is below:
import redis.clients.jedis.Jedis;
import java.util.Set;
String new_pattern = "*WITHDRAW_RISK_CONTROL_*";
Set<String> keysSet = null;
System.out.println("here****************");
and Set<String> keySet =null
doesn't work. I imported Set import java.util.Set;
Is this a Jmeter problem? or for some reason?
Second question: it can recognize the class Jedis
in the Jedis jar. But it can't support Jedis JedisPoolConfig why?
source to share
- The diamond operator was introduced in Java 7 which came out in 2011.
- JMeter ships with Beanshell 2.0b5 released in 2005.
As such, Java 7 features are not expected to be supported by the rather outdated Beanshell interpreter. It should work if you remove the bit <String>
.
I expect the problem to live somewhere else. To debug your Beanshell script you can try the following approaches:
- Add the directive
debug();
at the very beginning of your script. This will output debug information to STDOUT (where you expect your line tohere****************
) -
Wrap suspicious code in try / catch block like
try { // your Beanshell // code here } catch (Throwable ex) { log.info("Something went wrong", ex); }
Inspect the jmeter.log file for details of the failure.
See How To Use BeanShell: A Favorite Built-In JMeter Component for more information on Beanshell scripting in JMeter.
source to share