fix tri stub exception (#12093)

* fix tri stub exception

* fix
This commit is contained in:
earthchen 2023-04-14 17:20:30 +08:00 committed by GitHub
parent d73aca8847
commit 129b4fa2fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -34,7 +34,11 @@ public class UnaryStubMethodHandler<T, R> implements StubMethodHandler<T, R> {
T request = (T) arguments[0];
CompletableFuture<R> future = new CompletableFuture<>();
StreamObserver<R> responseObserver = new FutureToObserverAdaptor<>(future);
func.accept(request, responseObserver);
try {
func.accept(request, responseObserver);
} catch (Throwable e) {
future.completeExceptionally(e);
}
return future;
}
}