Am 03.07.2018 23:15, schrieb Philippe Mouawad:
This commit breaks build.

For comments see below (very far down).


Regards

On Tuesday, July 3, 2018, <[email protected]> wrote:

Author: pmouawad
Date: Tue Jul  3 20:16:38 2018
New Revision: 1835022

URL: http://svn.apache.org/viewvc?rev=1835022&view=rev
Log:
Bug 62238 - Add ability to Switch to next iteration of Current Loop

Fix issue in nightly
Bugzilla Id: 62238

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/control/
ForeachController.java
    jmeter/trunk/src/core/org/apache/jmeter/control/
IteratingController.java
jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java jmeter/trunk/src/core/org/apache/jmeter/control/WhileController.java

Modified: jmeter/trunk/src/components/org/apache/jmeter/control/
ForeachController.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/
org/apache/jmeter/control/ForeachController.java?rev=
1835022&r1=1835021&r2=1835022&view=diff
============================================================
==================
--- jmeter/trunk/src/components/org/apache/jmeter/control/ForeachController.java
(original)
+++ jmeter/trunk/src/components/org/apache/jmeter/control/ForeachController.java
Tue Jul  3 20:16:38 2018
@@ -20,6 +20,7 @@ package org.apache.jmeter.control;

 import java.io.Serializable;

+import org.apache.jmeter.engine.event.LoopIterationEvent;
 import org.apache.jmeter.gui.GUIMenuSortOrder;
 import org.apache.jmeter.samplers.Sampler;
 import org.apache.jmeter.testelement.property.BooleanProperty;
@@ -318,4 +319,10 @@ public class ForeachController extends G
         resetLoopCount();
         recoverRunningVersion();
     }
+
+    @Override
+    public void iterationStart(LoopIterationEvent iterEvent) {
+        reInitialize();
+        resetLoopCount();
+    }
 }

Modified: jmeter/trunk/src/core/org/apache/jmeter/control/
IteratingController.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/
apache/jmeter/control/IteratingController.java?rev=
1835022&r1=1835021&r2=1835022&view=diff
============================================================
==================
--- jmeter/trunk/src/core/org/apache/jmeter/control/IteratingController.java
(original)
+++ jmeter/trunk/src/core/org/apache/jmeter/control/IteratingController.java
Tue Jul  3 20:16:38 2018
@@ -18,6 +18,7 @@

 package org.apache.jmeter.control;

+import org.apache.jmeter.engine.event.LoopIterationListener;
 import org.apache.jmeter.threads.JMeterContextService;
 import org.apache.jmeter.threads.JMeterVariables;
 import org.apache.jmeter.util.JMeterUtils;
@@ -26,7 +27,7 @@ import org.apache.jmeter.util.JMeterUtil
  * Identify controller that does iterations
  * @since 4.1
  */
-public interface IteratingController {
+public interface IteratingController extends LoopIterationListener {

     /**
      * Start next iteration ("continue" keyword equivalent in loops)

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=
1835022&r1=1835021&r2=1835022&view=diff
============================================================
==================
--- jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java
(original)
+++ jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java
Tue Jul  3 20:16:38 2018
@@ -20,23 +20,27 @@ package org.apache.jmeter.control;

 import java.io.Serializable;

+import org.apache.jmeter.engine.event.LoopIterationEvent;
+import org.apache.jmeter.engine.event.LoopIterationListener;
 import org.apache.jmeter.samplers.Sampler;
 import org.apache.jmeter.testelement.property.BooleanProperty;
 import org.apache.jmeter.testelement.property.IntegerProperty;
 import org.apache.jmeter.testelement.property.JMeterProperty;
 import org.apache.jmeter.testelement.property.StringProperty;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;

 /**
* Class that implements the Loop Controller, ie iterate infinitely or a
configured number of times
  */
-public class LoopController extends GenericController implements
Serializable, IteratingController {
+public class LoopController extends GenericController implements
Serializable, IteratingController, LoopIterationListener {

     public static final int INFINITE_LOOP_COUNT = -1; // $NON-NLS-1$

     public static final String LOOPS = "LoopController.loops"; //
$NON-NLS-1$

private static final long serialVersionUID = 7833960784370272300L;
-
+    private static final Logger LOGGER = LoggerFactory.getLogger(
LoopController.class);
     /**
* In spite of the name, this is actually used to determine if the
loop controller is repeatable.
      *
@@ -221,4 +225,13 @@ public class LoopController extends Gene
         resetLoopCount();
         recoverRunningVersion();
     }
+
+    @Override
+    public void iterationStart(LoopIterationEvent iterEvent) {
+        if(LOGGER.isInfoEnabled()) {
+ LOGGER.info("iterationStart called on {} with source {} and iteration {}", getName(), iterEvent.getSource(), iterEvent.getIteration());
+        }
+        reInitialize();
+        resetLoopCount();
+    }
 }

Modified: jmeter/trunk/src/core/org/apache/jmeter/control/
WhileController.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/
apache/jmeter/control/WhileController.java?rev=
1835022&r1=1835021&r2=1835022&view=diff
============================================================
==================
--- jmeter/trunk/src/core/org/apache/jmeter/control/WhileController.java
(original)
+++ jmeter/trunk/src/core/org/apache/jmeter/control/WhileController.java
Tue Jul  3 20:16:38 2018
@@ -20,6 +20,7 @@ package org.apache.jmeter.control;

 import java.io.Serializable;

+import org.apache.jmeter.engine.event.LoopIterationEvent;
 import org.apache.jmeter.samplers.Sampler;
 import org.apache.jmeter.testelement.property.JMeterProperty;
 import org.apache.jmeter.testelement.property.StringProperty;
@@ -160,4 +161,11 @@ public class WhileController extends Gen
         resetLoopCount();
         recoverRunningVersion();
     }
+
+    @Override
+    public void iterationStart(LoopIterationEvent iterEvent) {
+        reInitialize();
+        endOfLoop(true);

The exception happens here. I believe it is because the Counter is not initialized yet and the jexl expression is testet on "${counter} != 10", but there is no variable named counter and therefor it doesn't get replaced.

I am not sure, whether we should just ignore any exceptions (log them and use an empty string as alternative) in endOfLoop(true), or if we should require, that one has to
define the variable upfront.

Regards,
 Felix

+        resetLoopCount();
+    }
 }



Reply via email to