From 0d69547363e312a97298acdf32cd4992ed7f09ed Mon Sep 17 00:00:00 2001 From: shenjianeng Date: Sat, 9 Apr 2022 23:35:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:condition=E8=A2=AB=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E4=BA=86=E4=B8=A4=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/alibaba/cola/statemachine/Transition.java | 2 +- .../com/alibaba/cola/statemachine/impl/StateMachineImpl.java | 2 +- .../com/alibaba/cola/statemachine/impl/TransitionImpl.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cola-components/cola-component-statemachine/src/main/java/com/alibaba/cola/statemachine/Transition.java b/cola-components/cola-component-statemachine/src/main/java/com/alibaba/cola/statemachine/Transition.java index 945253b36..5247fc40a 100644 --- a/cola-components/cola-component-statemachine/src/main/java/com/alibaba/cola/statemachine/Transition.java +++ b/cola-components/cola-component-statemachine/src/main/java/com/alibaba/cola/statemachine/Transition.java @@ -57,7 +57,7 @@ public interface Transition{ * @return the target state */ - State transit(C ctx); + State transit(C ctx, boolean checkCondition); /** * Verify transition correctness */ diff --git a/cola-components/cola-component-statemachine/src/main/java/com/alibaba/cola/statemachine/impl/StateMachineImpl.java b/cola-components/cola-component-statemachine/src/main/java/com/alibaba/cola/statemachine/impl/StateMachineImpl.java index 05d78bde1..f36fa83d3 100644 --- a/cola-components/cola-component-statemachine/src/main/java/com/alibaba/cola/statemachine/impl/StateMachineImpl.java +++ b/cola-components/cola-component-statemachine/src/main/java/com/alibaba/cola/statemachine/impl/StateMachineImpl.java @@ -40,7 +40,7 @@ public S fireEvent(S sourceStateId, E event, C ctx) { return sourceStateId; } - return transition.transit(ctx).getId(); + return transition.transit(ctx, false).getId(); } private Transition routeTransition(S sourceStateId, E event, C ctx) { diff --git a/cola-components/cola-component-statemachine/src/main/java/com/alibaba/cola/statemachine/impl/TransitionImpl.java b/cola-components/cola-component-statemachine/src/main/java/com/alibaba/cola/statemachine/impl/TransitionImpl.java index 357299e5f..3ea21e4fa 100644 --- a/cola-components/cola-component-statemachine/src/main/java/com/alibaba/cola/statemachine/impl/TransitionImpl.java +++ b/cola-components/cola-component-statemachine/src/main/java/com/alibaba/cola/statemachine/impl/TransitionImpl.java @@ -83,10 +83,10 @@ public void setAction(Action action) { } @Override - public State transit(C ctx) { + public State transit(C ctx, boolean checkCondition) { Debugger.debug("Do transition: "+this); this.verify(); - if(condition == null || condition.isSatisfied(ctx)){ + if (!checkCondition || condition == null || condition.isSatisfied(ctx)) { if(action != null){ action.execute(source.getId(), target.getId(), event, ctx); }