Bug 43694 - ForEach Controller (empty collection processing error)
ForEach Controller (empty collection processing error)
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: Main
2.3
Other other
: P2 normal (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2007-10-24 12:04 UTC by Dmitry Kudrenko
Modified: 2007-10-24 17:36 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Kudrenko 2007-10-24 12:04:07 UTC
If ForEach Controller used in the cycle and input collection is empty at the
first n iterations and not empty starting from the n+1 iteration then ForEach
starts to process collections from n+1 element.

Example
Short plan description:
Thread Group
-While (several times)
--HTTP Request
---RegExp Extractor (receives collection ‘input’)		
--ForEach (input:out)
---HTTP Request using out value

First iteration: input is empty
Second iteration: input {element1, element2, element3}
For each will process started from element2.
Comment 1 Dmitry Kudrenko 2007-10-24 12:18:04 UTC
(In reply to comment #0)
> If ForEach Controller used in the cycle and input collection is empty at the
> first n iterations and not empty starting from the n+1 iteration then ForEach
> starts to process collections from n+1 element.
> 
> Example
> Short plan description:
> Thread Group
> -While (several times)
> --HTTP Request
> ---RegExp Extractor (receives collection ‘input’)		
> --ForEach (input:out)
> ---HTTP Request using out value
> 
> First iteration: input is empty
> Second iteration: input {element1, element2, element3}
> For each will process started from element2.

Seems the problem in the org.apache.jmeter.control.ForeachController.next() method. 

As I understand, It should reset loop counter if collection is empty.

 public Sampler next() {
	if (emptyList()) {
		reInitialize();
+		resetLoopCount();
		return null;
	}
	return super.next();
 }

Comment 2 Sebb 2007-10-24 17:36:12 UTC
Thanks very much for the report and the patch.

I can confirm the problem, and the patch fixes it - good work.

Applied to SVN in r588094