jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1225667 - /jmeter/trunk/src/components/org/apache/jmeter/modifiers/CounterConfig.java
Date Thu, 29 Dec 2011 22:01:42 GMT
Author: pmouawad
Date: Thu Dec 29 22:01:42 2011
New Revision: 1225667

URL: http://svn.apache.org/viewvc?rev=1225667&view=rev
Log:
moved synchronized block to where it's needed

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/modifiers/CounterConfig.java

Modified: jmeter/trunk/src/components/org/apache/jmeter/modifiers/CounterConfig.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/modifiers/CounterConfig.java?rev=1225667&r1=1225666&r2=1225667&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/modifiers/CounterConfig.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/modifiers/CounterConfig.java Thu Dec 29
22:01:42 2011
@@ -55,6 +55,7 @@ public class CounterConfig extends Abstr
 	private static final boolean RESET_ON_THREAD_GROUP_ITERATION_DEFAULT = false;
 
     // This class is not cloned per thread, so this is shared
+	//@GuardedBy("this")
     private long globalCounter = Long.MIN_VALUE;
 
     // Used for per-thread/user numbers
@@ -91,20 +92,24 @@ public class CounterConfig extends Abstr
     /**
      * @see LoopIterationListener#iterationStart(LoopIterationEvent)
      */
-    public synchronized void iterationStart(LoopIterationEvent event) {
+    public void iterationStart(LoopIterationEvent event) {
         // Cannot use getThreadContext() as not cloned per thread
         JMeterVariables variables = JMeterContextService.getContext().getVariables();
-        long start = getStart(), end = getEnd(), increment = getIncrement();
+        long start = getStart();
+        long end = getEnd();
+        long increment = getIncrement();
         if (!isPerUser()) {
-            if (globalCounter == Long.MIN_VALUE || globalCounter > end) {
-                globalCounter = start;
-            }
-            variables.put(getVarName(), formatNumber(globalCounter));
-            globalCounter += increment;
+        	synchronized (this) {
+                if (globalCounter == Long.MIN_VALUE || globalCounter > end) {
+                    globalCounter = start;
+                }
+                variables.put(getVarName(), formatNumber(globalCounter));
+                globalCounter += increment;				
+			}
         } else {
         	long current = perTheadNumber.get().longValue();
         	if(isResetOnThreadGroupIteration()) {
-            	int iteration = JMeterContextService.getContext().getVariables().getIteration();
+            	int iteration = variables.getIteration();
 	        	Long lastIterationNumber = perTheadLastIterationNumber.get();
 	        	if(iteration != lastIterationNumber.longValue()) {
 	        		// reset 



Mime
View raw message