Skip to content

Commit 3f70ca9

Browse files
Fix
1 parent 230bd21 commit 3f70ca9

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public void tryCancel() {
122122

123123
@Override
124124
public void tryComplete(NotificationReader reader) {
125+
if (this.isDone()) return;
125126
reader
126127
.take(handle)
127128
.ifPresent(
@@ -174,6 +175,7 @@ public void tryCancel() {
174175

175176
@Override
176177
public void tryComplete(NotificationReader reader) {
178+
if (this.isDone()) return;
177179
asyncResult.tryComplete(reader);
178180
}
179181

@@ -292,6 +294,7 @@ public void tryCancel() {
292294

293295
@Override
294296
public void tryComplete(NotificationReader reader) {
297+
if (this.isDone()) return;
295298
asyncResults.forEach(ar -> ar.tryComplete(reader));
296299
for (int i = 0; i < asyncResults.size(); i++) {
297300
if (asyncResults.get(i).isDone()) {
@@ -341,6 +344,7 @@ public void tryCancel() {
341344

342345
@Override
343346
public void tryComplete(NotificationReader reader) {
347+
if (this.isDone()) return;
344348
asyncResults.forEach(ar -> ar.tryComplete(reader));
345349
asyncResults.stream()
346350
.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+
AwaitResult doAwait(UnresolvedFuture future);
9191

9292
sealed interface NotificationValue {
9393

0 commit comments

Comments
 (0)