Prevent race condition when flow transition is not initialized
Resolves #4092
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
5e515473de
commit
99e8d58c13
@@ -48,6 +48,7 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
* @author Dave Syer
|
||||
* @author Michael Minella
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @author Taeik Lim
|
||||
* @since 2.0
|
||||
*/
|
||||
public class SimpleFlow implements Flow, InitializingBean {
|
||||
@@ -124,9 +125,7 @@ public class SimpleFlow implements Flow, InitializingBean {
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
if (startState == null) {
|
||||
initializeTransitions();
|
||||
}
|
||||
initializeTransitionsIfNotInitialized();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,9 +133,8 @@ public class SimpleFlow implements Flow, InitializingBean {
|
||||
*/
|
||||
@Override
|
||||
public FlowExecution start(FlowExecutor executor) throws FlowExecutionException {
|
||||
if (startState == null) {
|
||||
initializeTransitions();
|
||||
}
|
||||
initializeTransitionsIfNotInitialized();
|
||||
|
||||
State state = startState;
|
||||
String stateName = state.getName();
|
||||
return resume(stateName, executor);
|
||||
@@ -262,6 +260,12 @@ public class SimpleFlow implements Flow, InitializingBean {
|
||||
return continued;
|
||||
}
|
||||
|
||||
private synchronized void initializeTransitionsIfNotInitialized() {
|
||||
if (startState == null) {
|
||||
initializeTransitions();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyse the transitions provided and generate all the information needed to execute
|
||||
* the flow.
|
||||
|
||||
Reference in New Issue
Block a user