BATCH-1065: Added check to ensure that a transition from an EndState does not have a "pattern" associated. EndState transitions must always be universal.
This commit is contained in:
@@ -46,9 +46,10 @@ public interface State {
|
||||
FlowExecutionStatus handle(FlowExecutor executor) throws Exception;
|
||||
|
||||
/**
|
||||
* Validate that the nextState is appropriate for this State.
|
||||
* Validate that the transition attributes are appropriate for this State.
|
||||
*
|
||||
* @param pattern
|
||||
* @param nextState
|
||||
*/
|
||||
void validate(String nextState);
|
||||
void validate(String pattern, String nextState);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class StateTransition implements Comparable<StateTransition> {
|
||||
}
|
||||
|
||||
Assert.notNull(state, "A state is required for a StateTransition");
|
||||
state.validate(next);
|
||||
state.validate(pattern, next);
|
||||
|
||||
this.next = next;
|
||||
this.state = state;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class DecisionState extends AbstractState {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.job.flow.State#validate(java.lang.String)
|
||||
*/
|
||||
public void validate(String nextState) {
|
||||
public void validate(String pattern, String nextState) {
|
||||
if (nextState == null) {
|
||||
throw new IllegalStateException("The transition for " + getClass().getSimpleName() + " [" + getName()
|
||||
+ "] requires a 'next' state.");
|
||||
|
||||
@@ -83,11 +83,15 @@ public class EndState extends AbstractState {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.job.flow.State#validate(java.lang.String)
|
||||
*/
|
||||
public void validate(String nextState) {
|
||||
public void validate(String pattern, String nextState) {
|
||||
if (status != BatchStatus.INCOMPLETE && nextState != null) {
|
||||
throw new IllegalStateException("The transition for " + getClass().getSimpleName() + " [" + getName()
|
||||
+ "] may not have a 'next' state.");
|
||||
}
|
||||
if (pattern != null) {
|
||||
throw new IllegalStateException("The transition for " + getClass().getSimpleName() + " [" + getName()
|
||||
+ "] may not have a 'pattern'.");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -106,7 +106,7 @@ public class SplitState extends AbstractState {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.job.flow.State#validate(java.lang.String)
|
||||
*/
|
||||
public void validate(String nextState) {
|
||||
public void validate(String pattern, String nextState) {
|
||||
if (nextState == null) {
|
||||
throw new IllegalStateException("The transition for " + getClass().getSimpleName() + " [" + getName()
|
||||
+ "] requires a 'next' state.");
|
||||
|
||||
@@ -65,7 +65,7 @@ public class StepState extends AbstractState implements StepHolder {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.job.flow.State#validate(java.lang.String)
|
||||
*/
|
||||
public void validate(String nextState) {
|
||||
public void validate(String pattern, String nextState) {
|
||||
if (nextState == null) {
|
||||
throw new IllegalStateException("The transition for " + getClass().getSimpleName() + " [" + getName()
|
||||
+ "] requires a 'next' state.");
|
||||
|
||||
@@ -50,6 +50,6 @@ public class StateSupport extends AbstractState {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public void validate(String nextState) {
|
||||
public void validate(String pattern, String nextState) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user