Fix infinite loop in FlowBuilder#next()

Resolves #4432
This commit is contained in:
injae.kim
2023-10-25 20:26:27 +09:00
committed by Mahmoud Ben Hassine
parent 7fd34829f9
commit 4a67b22e90
2 changed files with 94 additions and 22 deletions

View File

@@ -48,6 +48,7 @@ import org.springframework.core.task.TaskExecutor;
* @author Dave Syer
* @author Michael Minella
* @author Mahmoud Ben Hassine
* @author Injae Kim
* @since 2.2
* @param <Q> the type of object returned by the builder (by default a Flow)
*
@@ -107,7 +108,8 @@ public class FlowBuilder<Q> {
/**
* Transition to the next step on successful completion of the current step. All other
* outcomes are treated as failures.
* outcomes are treated as failures. If no steps are registered yet, then this method
* will behave in the same way as {@link #start(Step)}.
* @param step the next step
* @return this to enable chaining
*/
@@ -250,26 +252,32 @@ public class FlowBuilder<Q> {
if (this.currentState == null) {
doStart(input);
}
State next = createState(input);
addTransition("COMPLETED", next);
addTransition("*", failedState);
this.currentState = next;
else {
State next = createState(input);
addTransition("COMPLETED", next);
addTransition("*", failedState);
this.currentState = next;
}
}
private void doStart(Object input) {
if (this.currentState != null) {
doFrom(input);
}
this.currentState = createState(input);
else {
this.currentState = createState(input);
}
}
private void doFrom(Object input) {
if (currentState == null) {
doStart(input);
}
State state = createState(input);
tos.put(currentState.getName(), currentState);
this.currentState = state;
else {
State state = createState(input);
tos.put(currentState.getName(), currentState);
this.currentState = state;
}
}
private State createState(Object input) {