Bug 40851

Summary: - Loop controller with 0 iterations, stops evaluating the iterations field
Product: JMeter - Now in Github Reporter: Nikolay Diakov <nikolay.diakov>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: P2    
Version: 2.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: Test plan to show the bug
Suggested patch

Description Nikolay Diakov 2006-10-31 03:05:54 UTC
We have a "loop" controler, the number of iterations of which depends on a 
BeanShell function. That function returns random number in some integer range. 
When the function returns a 0, the "loop" controller code re-evaluating the 
iterations field! This means if we want to run a user thread of 1000 runs with 
a "loop" controler that does iterations 3, 2, 4, 1, 0, 3, 2, 4, 1, 0, ... and 
so on each user run, the first time the iteration number hits 0, it stays 0.

We made a work around with an "if" controller that checks whether we have a 0 
and does not pass it to the loop controller.

Cheers,
  Nik
Comment 1 Alf Hogemark 2007-05-11 05:49:32 UTC
Created attachment 20177 [details]
Test plan to show the bug

You will need to make a CSV file named "no_iterations.csv", with the number of
iteration of the loop for each iteration of the threadgroup, for example like
this :
2
1
0
3

You will see that you only get 3 samples (2+1).
Comment 2 Alf Hogemark 2007-05-11 05:55:18 UTC
Created attachment 20178 [details]
Suggested patch

This suggested patch causes the the loop evaluation to be executed on each
iteration, even if the loop has had a "Loop count" of value 0 in earlier
iterations.

This can be useful for example if you are looping over company and their
customers as an example. If some company has 0 customers, this bug means that
the "customers" loop will never again be entered, even if the next company has
4 customers.
Comment 3 Sebb 2007-05-13 14:36:33 UTC
Thanks - applied to SVN in r537660
Comment 4 The ASF infrastructure team 2022-09-24 20:37:38 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/1819