diff --git a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftInvoker.java b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftInvoker.java index 3b0e3d9352f..e23500343e4 100644 --- a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftInvoker.java +++ b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftInvoker.java @@ -96,7 +96,13 @@ protected Result doInvoke(Invocation invocation) throws Throwable { AsyncRpcResult asyncRpcResult = new AsyncRpcResult(invocation); CompletableFuture responseFuture = currentClient.request(inv, timeout); - asyncRpcResult.subscribeTo(responseFuture); + responseFuture.whenComplete((obj, t) -> { + if (t != null) { + asyncRpcResult.completeExceptionally(t); + } else { + asyncRpcResult.complete((Result) obj); + } + }); RpcContext.getContext().setFuture(new FutureAdapter(asyncRpcResult)); return asyncRpcResult; } catch (TimeoutException e) {