https://issues.apache.org/bugzilla/show_bug.cgi?id=47646
Summary: NullPointerException in the "Random Variable" element
Product: JMeter
Version: 2.3.4
Platform: All
OS/Version: All
Status: NEW
Severity: major
Priority: P2
Component: Main
AssignedTo: [email protected]
ReportedBy: [email protected]
--- Comment #0 from Miguel Parreño <[email protected]> 2009-08-05 03:24:57
PDT ---
In a "Random Variable" element set true the "Per Thread(User)" option, and
launch test plan in distributed mode (Remote Start).
ERROR - jmeter.threads.JMeterThread: Test failed!
java.lang.NullPointerException
at
org.apache.jmeter.config.RandomVariableConfig.iterationStart(RandomVariableConfig.java:90)
at
org.apache.jmeter.control.GenericController.fireIterationStart(GenericController.java:318)
at
org.apache.jmeter.control.GenericController.fireIterEvents(GenericController.java:308)
at
org.apache.jmeter.control.GenericController.next(GenericController.java:128)
at
org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:182)
at
org.apache.jmeter.control.GenericController.next(GenericController.java:146)
at
org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:185)
at
org.apache.jmeter.control.GenericController.next(GenericController.java:146)
at
org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:182)
at
org.apache.jmeter.control.GenericController.next(GenericController.java:146)
at
org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:182)
at
org.apache.jmeter.control.GenericController.next(GenericController.java:146)
at org.apache.jmeter.control.LoopController.next(LoopController.java:109)
at org.apache.jmeter.threads.ThreadGroup.next(ThreadGroup.java:129)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:242)
at java.lang.Thread.run(Unknown Source)
The method:
public void iterationStart(LoopIterationEvent iterEvent) {
Random randGen=null;
if (getPerThread()){
randGen = (Random) perThreadRandom.get(); <------ At line
90, the perThreadRandom object IS NULL.
} else {
synchronized(this){
if (globalRandom == null){
init();
globalRandom = new Random(getRandomSeedAsLong());
}
randGen=globalRandom;
}
}
if (n <=0){
return;
}
long nextRand = minimum + randGen.nextInt(n);
// Cannot use getThreadContext() as we are not cloned per thread
JMeterVariables variables =
JMeterContextService.getContext().getVariables();
variables.put(getVariableName(), formatNumber(nextRand));
}
The declaration:
private transient ThreadLocal perThreadRandom = new ThreadLocal() {
protected Object initialValue() {
init();
return new Random(getRandomSeedAsLong());
}};
¿Why transient? Javadoc says that ThreadLocal instances are typically private
static fields in classes that wish to associate state with a thread. However,
in this case not in possible, because init() and getRandomSeedAsLong() are
non-static methods in the class. I comment out these calls, set static the
declaration and work fine.
References: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ThreadLocal.html
I use: java version "1.6.0_14"
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]