Skip to content

Commit 70dfad3

Browse files
Fix little issue with doProgress loop
1 parent fc41383 commit 70dfad3

6 files changed

Lines changed: 12 additions & 10 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ private void pollAsyncResultInner(AsyncResultInternal<?> asyncResult) {
382382

383383
// Now let's take the unprocessed leaves
384384
List<Integer> uncompletedLeaves = asyncResult.uncompletedLeaves().toList();
385-
if (uncompletedLeaves.size() == 1) {
385+
if (uncompletedLeaves.isEmpty()) {
386386
// Nothing else to do!
387387
return;
388388
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ProtocolException extends RuntimeException {
1616
static final int NOT_FOUND_CODE = 404;
1717
public static final int UNSUPPORTED_MEDIA_TYPE_CODE = 415;
1818
public static final int INTERNAL_CODE = 500;
19-
public static final int UNSUPPORTED_FEATURE = 573;
19+
@Deprecated public static final int UNSUPPORTED_FEATURE = 573;
2020

2121
private final int code;
2222

@@ -43,6 +43,7 @@ public static ProtocolException methodNotFound(String serviceName, String handle
4343
"Cannot find handler '" + serviceName + "/" + handlerName + "'", NOT_FOUND_CODE);
4444
}
4545

46+
@Deprecated
4647
public static ProtocolException idempotencyKeyIsEmpty() {
4748
return new ProtocolException(
4849
"The provided idempotency key is empty.",

sdk-core/src/main/java/dev/restate/sdk/core/sharedcore/SharedCoreInstance.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.dylibso.chicory.wasm.WasmModule;
1818
import com.fasterxml.jackson.core.JsonProcessingException;
1919
import com.fasterxml.jackson.dataformat.cbor.databind.CBORMapper;
20+
import dev.restate.sdk.core.ProtocolException;
2021
import dev.restate.sdk.core.sharedcore.generated.SharedCoreWasmMachine;
2122
import java.io.IOException;
2223
import java.util.function.Function;
@@ -79,7 +80,7 @@ public <T> T readCborAndFree(long packed, Class<T> outputClazz) {
7980
try {
8081
return CBOR.readValue(retBytes, outputClazz);
8182
} catch (IOException e) {
82-
throw new RuntimeException("Failed to decode CBOR", e);
83+
throw new ProtocolException("Failed to decode CBOR", ProtocolException.INTERNAL_CODE, e);
8384
}
8485
}
8586

@@ -96,7 +97,7 @@ public BufferPointer writeCbor(Object input) {
9697
try {
9798
cbor = CBOR.writeValueAsBytes(input);
9899
} catch (JsonProcessingException e) {
99-
throw new RuntimeException("Failed to encode CBOR", e);
100+
throw new ProtocolException("Failed to encode CBOR", ProtocolException.INTERNAL_CODE, e);
100101
}
101102
int ptr = write(cbor);
102103
return new BufferPointer(ptr, cbor.length);

sdk-core/src/main/java/dev/restate/sdk/core/sharedcore/SharedCoreVM.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.fasterxml.jackson.annotation.JsonTypeInfo;
1313
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
1414
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
15+
import dev.restate.sdk.core.ProtocolException;
1516
import dev.restate.sdk.endpoint.HeadersAccessor;
1617
import java.util.ArrayList;
1718
import java.util.Collections;
@@ -64,8 +65,7 @@ public static SharedCoreVM create(HeadersAccessor headersAccessor) {
6465
.collect(Collectors.toList())),
6566
VmNewReturn.class);
6667
if (newVmReturn instanceof VmNewReturn.Failure f) {
67-
throw new RuntimeException(
68-
"Failed to create state machine: " + f.code() + ": " + f.message());
68+
throw new ProtocolException("Failed to create state machine: " + f.message(), f.code);
6969
}
7070
int vmPtr = ((VmNewReturn.Ok) newVmReturn).pointer();
7171
return new SharedCoreVM(instance, vmPtr);
@@ -825,8 +825,8 @@ private void callWithEmptyReturn(BiFunction<SharedCoreWasm_ModuleExports, Intege
825825
if (ret instanceof EmptyReturn.Failure f) throw vmError(f.code, f.message);
826826
}
827827

828-
private static RuntimeException vmError(int code, String message) {
829-
return new RuntimeException("VM error " + code + ": " + message);
828+
private static ProtocolException vmError(int code, String message) {
829+
return new ProtocolException(message, code);
830830
}
831831

832832
private static List<String[]> toHeaderList(@Nullable List<Map.Entry<String, String>> headers) {

sdk-core/src/main/rust/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk-core/src/main/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77
crate-type = ["cdylib"]
88

99
[dependencies]
10-
restate-sdk-shared-core = { git = "https://github.com/restatedev/sdk-shared-core", branch = "awaiting_on", features = ["tracing_pretty"] }
10+
restate-sdk-shared-core = { git = "https://github.com/restatedev/sdk-shared-core", branch = "main", features = ["tracing_pretty"] }
1111
bytes = "1"
1212
serde = { version = "1", features = ["derive"] }
1313
serde_bytes = "0.11"

0 commit comments

Comments
 (0)