Skip to content

Commit 6f1170a

Browse files
Fix
1 parent 230bd21 commit 6f1170a

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void tryCancel() {
121121
}
122122

123123
@Override
124-
public void tryComplete(NotificationReader reader) {
124+
public void tryComplete(NotificationReader reader) { if (this.isDone()) return;
125125
reader
126126
.take(handle)
127127
.ifPresent(
@@ -173,7 +173,7 @@ public void tryCancel() {
173173
}
174174

175175
@Override
176-
public void tryComplete(NotificationReader reader) {
176+
public void tryComplete(NotificationReader reader) { if (this.isDone()) return;
177177
asyncResult.tryComplete(reader);
178178
}
179179

@@ -291,7 +291,7 @@ public void tryCancel() {
291291
}
292292

293293
@Override
294-
public void tryComplete(NotificationReader reader) {
294+
public void tryComplete(NotificationReader reader) { if (this.isDone()) return;
295295
asyncResults.forEach(ar -> ar.tryComplete(reader));
296296
for (int i = 0; i < asyncResults.size(); i++) {
297297
if (asyncResults.get(i).isDone()) {
@@ -341,6 +341,7 @@ public void tryCancel() {
341341

342342
@Override
343343
public void tryComplete(NotificationReader reader) {
344+
if (this.isDone()) return;
344345
asyncResults.forEach(ar -> ar.tryComplete(reader));
345346
asyncResults.stream()
346347
.filter(ar -> ar.publicFuture().isCompletedExceptionally())

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,6 @@ private void pollAsyncResultInner(AsyncResultInternal<?> asyncResult) {
423423
asyncResult.publicFuture().completeExceptionally(AbortedExecutionException.INSTANCE);
424424
return;
425425
}
426-
if (asyncResult.isDone()) {
427-
return;
428-
}
429426

430427
// Let's start by trying to complete it
431428
try {
@@ -436,6 +433,10 @@ private void pollAsyncResultInner(AsyncResultInternal<?> asyncResult) {
436433
asyncResult.publicFuture().completeExceptionally(AbortedExecutionException.INSTANCE);
437434
return;
438435
}
436+
// If done, nothing more to do here.
437+
if (asyncResult.isDone()) {
438+
return;
439+
}
439440

440441
// Not ready yet: make progress on what's still uncompleted. doAwait walks the async-result
441442
// tree directly (asyncResult is the await tree) and returns null when nothing is left to

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ record CancelSignalReceived() implements AwaitResult {}
8787
* AbortedExecutionException}, which should be treated as a clean abort of the user code, not a
8888
* failure to re-report.
8989
*/
90-
AwaitResult doAwait(UnresolvedFuture future);
90+
@Nullable AwaitResult doAwait(UnresolvedFuture future);
9191

9292
sealed interface NotificationValue {
9393

0 commit comments

Comments
 (0)