Author: sebb
Date: Thu Aug  6 00:28:21 2009
New Revision: 801478

URL: http://svn.apache.org/viewvc?rev=801478&view=rev
Log:
Bug 47646 -  NullPointerException in the "Random Variable" element

Modified:
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java
    jakarta/jmeter/trunk/xdocs/changes.xml

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java?rev=801478&r1=801477&r2=801478&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java
 Thu Aug  6 00:28:21 2009
@@ -54,15 +54,25 @@
     private Random globalRandom = null;
 
     // Used for per-thread/user numbers
-    private transient ThreadLocal perThreadRandom = new ThreadLocal() {
-            protected Object initialValue() {
-                init();
-                return new Random(getRandomSeedAsLong());
-            }};
+    // Cannot be static, as random numbers are not to be shared between 
instances
+    private transient ThreadLocal perThreadRandom = initThreadLocal();
+
+    private ThreadLocal initThreadLocal() {
+        return new ThreadLocal() {
+                protected Object initialValue() {
+                    init();
+                    return new Random(getRandomSeedAsLong());
+                }};
+    }
         
     private int n;
     private long minimum;
     
+    private Object readResolve(){
+        perThreadRandom = initThreadLocal();
+        return this;
+    }
+    
     /*
      * nextInt(n) returns values in the range [0,n),
      * so n must be set to max-min+1
@@ -84,6 +94,8 @@
         }
         n = (int)rangeL;
     }
+    
+    /** {...@inheritdoc} */
     public void iterationStart(LoopIterationEvent iterEvent) {
         Random randGen=null;
         if (getPerThread()){

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=801478&r1=801477&r2=801478&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Thu Aug  6 00:28:21 2009
@@ -97,6 +97,7 @@
 
 <h3>General</h3>
 <ul>
+<li>Bug 47646 -  NullPointerException in the "Random Variable" element</li>
 </ul>
 
 <!-- ==================================================== -->



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscr...@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-h...@jakarta.apache.org

Reply via email to