Bug description
If you create a "Flow" and use the "next" method instead of the "start" method to add the first step, then this step will be executed twice.
The problem is in the line addTransition("COMPLETED", next);. It is she who makes Flow perform the step a second time.
|
private void doNext(Object input) { |
Current version:
private void doNext(Object input) {
if (this.currentState == null) {
doStart(input);
}
State next = createState(input);
addTransition("COMPLETED", next);
addTransition("*", failedState);
this.currentState = next;
}
Fixed version:
private void doNext(Object input) {
if (this.currentState == null) {
doStart(input);
} else {
State next = createState(input);
addTransition("COMPLETED", next);
addTransition("*", failedState);
this.currentState = next;
}
}
Environment
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
<version>3.1.2</version>
Steps to reproduce
FlowBuilder<Flow> flowBuilder = new FlowBuilder<>("someFlowName");
flowBuilder.next(step);
return flowBuilder.build();
Expected behavior
Created "Flow" with one step. Step executed once.
Minimal Complete Reproducible example
The step was to transfer data from one table to another identical table. The second run of the step failed only because a unique primary key constraint was created.

Bug description
If you create a "Flow" and use the "next" method instead of the "start" method to add the first step, then this step will be executed twice.
The problem is in the line
addTransition("COMPLETED", next);. It is she who makes Flow perform the step a second time.spring-batch/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/FlowBuilder.java
Line 249 in e6c2727
Current version:
Fixed version:
Environment
Steps to reproduce
Expected behavior
Created "Flow" with one step. Step executed once.
Minimal Complete Reproducible example

The step was to transfer data from one table to another identical table. The second run of the step failed only because a unique primary key constraint was created.