Author: sebb Date: Sat Nov 8 17:25:03 2008 New Revision: 712458 URL: http://svn.apache.org/viewvc?rev=712458&view=rev Log: Bug 44941 - Throughput controllers should not share global counters
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/ThroughputController.java jakarta/jmeter/trunk/xdocs/changes.xml Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/ThroughputController.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/ThroughputController.java?rev=712458&r1=712457&r2=712458&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/ThroughputController.java (original) +++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/ThroughputController.java Sat Nov 8 17:25:03 2008 @@ -54,11 +54,25 @@ private static final String PERCENTTHROUGHPUT = "ThroughputController.percentThroughput";// $NON-NLS-1$ - private static int globalNumExecutions; + private static class MutableInteger{ + private int integer; + MutableInteger(int value){ + integer=value; + } + int incr(){ + return ++integer; + } + public int intValue() { + return integer; + } + } + + // These items are shared between threads in a group by the clone() method + private MutableInteger globalNumExecutions; - private static int globalIteration; + private MutableInteger globalIteration; - private static final Object counterLock = new Object(); // ensure counts are updated correctly + private Object counterLock = new Object(); // ensure counts are updated correctly /** * Number of iterations on which we've chosen to deliver samplers. @@ -154,7 +168,7 @@ private int getExecutions() { if (!isPerThread()) { synchronized (counterLock) { - return globalNumExecutions; + return globalNumExecutions.intValue(); } } return numExecutions; @@ -199,16 +213,20 @@ clone.numExecutions = numExecutions; clone.iteration = iteration; clone.runThisTime = false; + // Ensure global counters and lock are shared across threads in the group + clone.globalIteration = globalIteration; + clone.globalNumExecutions = globalNumExecutions; + clone.counterLock = counterLock; return clone; } public void iterationStart(LoopIterationEvent iterEvent) { if (!isPerThread()) { synchronized (counterLock) { - globalIteration++; - runThisTime = decide(globalNumExecutions, globalIteration); + globalIteration.incr(); + runThisTime = decide(globalNumExecutions.intValue(), globalIteration.intValue()); if (runThisTime) { - globalNumExecutions++; + globalNumExecutions.incr(); } } } else { @@ -222,8 +240,8 @@ public void testStarted() { synchronized (counterLock) { - globalNumExecutions = 0; - globalIteration = -1; + globalNumExecutions = new MutableInteger(0); + globalIteration = new MutableInteger(-1); } } Modified: jakarta/jmeter/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=712458&r1=712457&r2=712458&view=diff ============================================================================== --- jakarta/jmeter/trunk/xdocs/changes.xml (original) +++ jakarta/jmeter/trunk/xdocs/changes.xml Sat Nov 8 17:25:03 2008 @@ -156,6 +156,7 @@ <li>Bug 45460 - JMS TestPlan elements depend on resource property</li> <li>Bug 34096 - Duplicate samples not eliminated when writing to CSV files</li> <li>Bug 44521 - empty variables for a POST in the HTTP Request don't get ignored</li> +<li>Bug 44941 - Throughput controllers should not share global counters</li> </ul> <h3>Improvements</h3> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]