Skip to content

Commit 6e55d9e

Browse files
committed
fix: run short-circuit check first
1 parent e4d92d9 commit 6e55d9e

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

state-core/src/main/java/org/incendo/state/StateInteractionImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ record StateInteractionImpl<U extends State<U>, V extends Stateful<U, V>>(
5252

5353
try {
5454
final U currentState = this.instance.state();
55-
if (!this.incomingStates.contains(currentState)) {
56-
throw new UnexpectedStateException(this.incomingStates, currentState, this.instance);
57-
}
5855

5956
if (this.shortcircuitStates.contains(currentState)) {
6057
return this.instance;
6158
}
6259

60+
if (!this.incomingStates.contains(currentState)) {
61+
throw new UnexpectedStateException(this.incomingStates, currentState, this.instance);
62+
}
63+
6364
final V result = this.interaction.apply(this.instance);
6465

6566
final U newState = result.state();

0 commit comments

Comments
 (0)