I am Trying to use a Java request Sampler inside a ForEach Controller.
This is my custom Sampler
public class ClientSampler extends AbstractJavaSamplerClient {
String Name;
@Override
public Arguments getDefaultParameters() {
Arguments defaultParameters = new Arguments();
defaultParameters.addArgument("name", "Tarek");
return defaultParameters;
}
@Override
public void setupTest(JavaSamplerContext context) {
Name = context.getParameter("name");
}
@Override
public SampleResult runTest(JavaSamplerContext context) {
System.out.println(Name);
}
}
in Jmeter I create user defined variables with 5 variables:

And a ForEach Controller:

then added the java request as a child to ForEach controller:

the Test plan is the following:

when I start the test the output is:
first
first
first
first
first
expected:
first
second
third
fourth
fifth
even if I set the start and end indexes in the ForEach controller the result is the same.
using an http sampler inside the ForEach controller works great, but when using a Java requests the result is not as expected.
Can anyone explain why I am getting this output?