From ab44843b123b15a3a166069d4ac74aa2280095a9 Mon Sep 17 00:00:00 2001 From: Vaci Koblizek Date: Fri, 27 Nov 2020 15:24:37 +0000 Subject: [PATCH] QueuedClient should stop queuing calls once it has resolved --- .../src/main/java/org/capnproto/Capability.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/runtime/src/main/java/org/capnproto/Capability.java b/runtime/src/main/java/org/capnproto/Capability.java index 5abe634..8115b71 100644 --- a/runtime/src/main/java/org/capnproto/Capability.java +++ b/runtime/src/main/java/org/capnproto/Capability.java @@ -759,7 +759,12 @@ public final class Capability { @Override public Request newCall(long interfaceId, short methodId) { var hook = new LocalRequest(interfaceId, methodId, this); - this.pendingCalls.add(hook); + if (this.redirect == null) { + this.pendingCalls.add(hook); + } + else { + hook.releaseCall(); + } var root = hook.message.getRoot(AnyPointer.factory); return newTypelessRequest(root, hook); } @@ -767,7 +772,12 @@ public final class Capability { @Override public VoidPromiseAndPipeline call(long interfaceId, short methodId, CallContextHook ctx) { var promise = new CompletableFuture(); - this.queuedCalls.add(promise); + if (this.redirect == null) { + this.queuedCalls.add(promise); + } + else { + promise.complete(this.redirect); + } var callResult = promise.thenApply( client -> client.call(interfaceId, methodId, ctx));