diff --git a/runtime-rpc/src/main/java/org/capnproto/RpcState.java b/runtime-rpc/src/main/java/org/capnproto/RpcState.java index e922b66..29ef26c 100644 --- a/runtime-rpc/src/main/java/org/capnproto/RpcState.java +++ b/runtime-rpc/src/main/java/org/capnproto/RpcState.java @@ -1824,13 +1824,11 @@ final class RpcState { Integer importId) { this.cap = initial; this.importId = importId; - this.eventual = eventual.whenComplete((resolution, exc) -> { - if (exc == null) { - this.resolve(resolution); - } - else { - this.resolve(Capability.newBrokenCap(exc)); - } + this.eventual = eventual.handle((resolution, exc) -> { + this.cap = exc == null + ? this.resolve(resolution) + : this.resolve(Capability.newBrokenCap(exc)); + return this.cap; }); } @@ -1954,13 +1952,13 @@ final class RpcState { ClientHook finalReplacement = replacement; var embargoPromise = embargo.disembargo.thenApply( void_ -> finalReplacement); - replacement = Capability.newLocalPromiseClient(embargoPromise); LOGGER.info(() -> RpcState.this.toString() + ": > DISEMBARGO"); message.send(); + return Capability.newLocalPromiseClient(embargoPromise); + } + else { + return replacement; } - - this.cap = replacement; - return replacement; } }