Bug 64627

Summary: Programmatic manipulation of the control flow via API methods of JMeterContext is not working as it used to before 5.0
Product: JMeter - Now in Github Reporter: Philippe Mouawad <p.mouawad>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: major CC: p.mouawad
Priority: P2 Keywords: FixedInTrunk
Version: 5.0   
Target Milestone: JMETER_5.4   
Hardware: All   
OS: All   

Description Philippe Mouawad 2020-07-25 20:26:27 UTC
As reported in https://github.com/apache/jmeter/pull/606:
----------
Programmatic manipulation of the control flow via API methods of JMeterContext is not working as it used to.

When JMeter v5.0 introduced the "ability to Switch to next iteration of Current Loop" (see Bug 62238) the changes to JMeterThread were not entirely logically equivalent and broke some of our existing test when migrating to v5.x.

The simplest test plan to demonstrate this is as follows, where the Debug Sampler should never be run.
(This works up to JMeter v4.0 and fails in v5.0 and above.)

Test Plan
    \ Thread Group
        \ JSR223 Sampler
            ctx.setStartNextThreadLoop(true)
        \ Debug Sampler

Reason is the following change (refer here)

When processing the sample result, the "logical action" would only be changed if the result carried the "restart flag":

if(result.isStartNextThreadLoop()) {	            
    threadContext.setStartNextThreadLoop(true);	
}

But now the result unconditionally overwrites the context's "logical action":

threadContext.setTestLogicalAction(result.getTestLogicalAction());

This PR proposes to make the action change conditional again: only if different than CONTINUE

if (result.getTestLogicalAction() != TestLogicalAction.CONTINUE) {
    threadContext.setTestLogicalAction(result.getTestLogicalAction());
}


----------
Comment 1 Philippe Mouawad 2020-07-25 20:29:33 UTC
pmouawad pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new c0289a2  Fix for bug fix 62238 (#606)
c0289a2 is described below

commit c0289a2a76082036341e3f8f8602627b4a7fad60
Author: Till Neunast <tilln@users.noreply.github.com>
AuthorDate: Sun Jul 26 08:24:18 2020 +1200

    Fix for bug fix 62238 (#606)
---
 src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Comment 2 The ASF infrastructure team 2022-09-24 20:38:20 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/5369