@Override
public void run() {
// Can't use iterator in loop because it may cause
// ConcurrentModificationException
final List<Step> list = batch.getSteps();
Step step = null;
StepBlock currentBlock = null;
for (int i = 0; i < list.size(); i++) {
step = list.get(i);
try {
// if stop is requested : we stop execution of batch
if (!isStopRequested()) {
if (step.getBlockId() == 0) {
executeStep(i, step);
} else {
if (currentBlock == null) {
currentBlock = new StepBlock(step.getBlockIterationCount());
}
currentBlock.addStep(step);
if ((i == list.size() - 1)
|| (step.getBlockId() != list.get(i + 1).getBlockId())) {
executeBlock(i, currentBlock);
currentBlock = null;
}
}
}