Skip to content

Commit 0e711c9

Browse files
Fix unit tests
1 parent 6be1e3d commit 0e711c9

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

sdk-core/src/main/java/dev/restate/sdk/core/HandlerContextImpl.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,8 @@ private void pollAsyncResultInner(AsyncResultInternal<?> asyncResult) {
416416
} else if (response instanceof StateMachine.DoProgressResponse.ReadFromInput
417417
|| response instanceof StateMachine.DoProgressResponse.WaitingPendingRun) {
418418
this.stateMachine.onNextEvent(
419-
() -> {
420-
LOG.info("Triggered after wait {}", response);
421-
this.pollAsyncResultInner(asyncResult);
422-
});
419+
() -> this.pollAsyncResultInner(asyncResult),
420+
response instanceof StateMachine.DoProgressResponse.ReadFromInput);
423421
return;
424422
} else if (response instanceof StateMachine.DoProgressResponse.ExecuteRun) {
425423
triggerScheduledRun(((StateMachine.DoProgressResponse.ExecuteRun) response).handle());

sdk-core/src/main/java/dev/restate/sdk/core/statemachine/StateMachine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static StateMachine init(
4444

4545
// --- Await next event
4646

47-
void onNextEvent(Runnable runnable);
47+
void onNextEvent(Runnable runnable, boolean triggerNowIfInputClosed);
4848

4949
// --- Async results
5050

sdk-core/src/main/java/dev/restate/sdk/core/statemachine/StateMachineImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ public CompletableFuture<Void> waitForReady() {
7373
}
7474

7575
@Override
76-
public void onNextEvent(Runnable runnable) {
76+
public void onNextEvent(Runnable runnable, boolean triggerNowIfInputClosed) {
7777
this.nextEventListener =
7878
() -> {
7979
this.nextEventListener.run();
8080
runnable.run();
8181
};
8282
// Trigger this now
83-
if (this.stateContext.isInputClosed()) {
83+
if (triggerNowIfInputClosed && this.stateContext.isInputClosed()) {
8484
this.triggerNextEventSignal();
8585
}
8686
}

0 commit comments

Comments
 (0)