/** * Executes a unary call and returns a {@link ListenableFuture} to the response. * * @return a future for the single response message. */ public static <ReqT, RespT> ListenableFuture<RespT> futureUnaryCall( ClientCall<ReqT, RespT> call, ReqT param) { GrpcFuture<RespT> responseFuture = new GrpcFuture<RespT>(call); asyncUnaryRequestCall(call, param, new UnaryStreamToFuture<RespT>(responseFuture), false); return responseFuture; }
@Override public void onClose(Status status, Metadata trailers) { if (status.isOk()) { if (value == null) { // No value received so mark the future as an error responseFuture.setException( Status.INTERNAL.withDescription("No value received for unary call") .asRuntimeException(trailers)); } responseFuture.set(value); } else { responseFuture.setException(status.asRuntimeException(trailers)); } } }