You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2013/02/10 18:07:19 UTC

svn commit: r1444567 - /jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java

Author: pmouawad
Date: Sun Feb 10 17:07:19 2013
New Revision: 1444567

URL: http://svn.apache.org/r1444567
Log:
Bug 54467 - Loop controller Controller check conditions each request
Fix test failure
Bugzilla Id: 54467

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java?rev=1444567&r1=1444566&r2=1444567&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java Sun Feb 10 17:07:19 2013
@@ -31,7 +31,7 @@ import org.apache.jmeter.testelement.pro
  */
 public class LoopController extends GenericController implements Serializable {
 
-    private static final String LOOPS = "LoopController.loops"; // $NON-NLS-1$
+    public static final String LOOPS = "LoopController.loops"; // $NON-NLS-1$
 
     private static final long serialVersionUID = 7833960784370272300L;
 
@@ -67,12 +67,15 @@ public class LoopController extends Gene
     }
 
     public int getLoops() {
-        try {
-            JMeterProperty prop = getProperty(LOOPS);
-            return Integer.parseInt(prop.getStringValue());
-        } catch (NumberFormatException e) {
-            return 0;
+        if(nbLoops==null || nbLoops.intValue()==-1) {
+            try {
+                JMeterProperty prop = getProperty(LOOPS);
+                nbLoops = Integer.valueOf(prop.getStringValue());
+            } catch (NumberFormatException e) {
+                nbLoops = 0;
+            }
         }
+        return nbLoops.intValue();
     }
 
     public String getLoopString() {
@@ -112,11 +115,7 @@ public class LoopController extends Gene
     }
 
     private boolean endOfLoop() {
-        if(nbLoops==null) {
-            // Ensure we compute it only once per parent iteration, see Bug 54467
-            nbLoops = Integer.valueOf(getLoops());
-        }
-        final int loops = nbLoops.intValue();
+        final int loops = getLoops();
         return (loops > -1) && (loopCount >= loops);
     }