Skip to content

Commit e1b8d7f

Browse files
Fix cancellation test issue (#460)
Don't cancel child one way calls anymore
1 parent 5118ef6 commit e1b8d7f

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

sdk-common/src/main/java/dev/restate/sdk/types/TerminalException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ public class TerminalException extends RuntimeException {
1919
private final int code;
2020

2121
public TerminalException() {
22-
this.code = INTERNAL_SERVER_ERROR_CODE;
22+
this(INTERNAL_SERVER_ERROR_CODE);
2323
}
2424

2525
/** Like {@link #TerminalException(int, String)}, without message. */
2626
public TerminalException(int code) {
27-
this.code = code;
27+
this(code, "Error " + code);
2828
}
2929

3030
/**

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,7 @@ public CompletableFuture<AsyncResult<String>> send(
218218
int sendHandle =
219219
this.stateMachine.send(target, parameter, idempotencyKey, headers, delay);
220220

221-
AsyncResultInternal<String> invocationIdAsyncResult =
222-
AsyncResults.single(this, sendHandle, invocationIdCompleter());
223-
this.invocationIdsToCancel.add(invocationIdAsyncResult);
224-
225-
return invocationIdAsyncResult;
221+
return AsyncResults.single(this, sendHandle, invocationIdCompleter());
226222
});
227223
}
228224

test-services/src/main/kotlin/dev/restate/sdk/testservices/CancelTestImpl.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CancelTestImpl {
2424
}
2525

2626
override suspend fun startTest(context: ObjectContext, operation: BlockingOperation) {
27-
val client = CancelTestBlockingServiceClient.fromContext(context, "")
27+
val client = CancelTestBlockingServiceClient.fromContext(context, context.key())
2828

2929
try {
3030
client.block(operation).await()
@@ -44,8 +44,8 @@ class CancelTestImpl {
4444

4545
class BlockingService : CancelTest.BlockingService {
4646
override suspend fun block(context: ObjectContext, operation: BlockingOperation) {
47-
val self = CancelTestBlockingServiceClient.fromContext(context, "")
48-
val client = AwakeableHolderClient.fromContext(context, "cancel")
47+
val self = CancelTestBlockingServiceClient.fromContext(context, context.key())
48+
val client = AwakeableHolderClient.fromContext(context, context.key())
4949

5050
val awakeable = context.awakeable<String>()
5151
client.hold(awakeable.id).await()

0 commit comments

Comments
 (0)