From c3ea8e7c91c54d9af7d1086336812922527271a7 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Wed, 10 Jun 2020 12:21:46 -0700 Subject: [PATCH] stub: Document blocking exceptions and async extension types invoke() needed to be re-defined for Javadoc to display the method. --- .../main/java/io/grpc/stub/ClientCalls.java | 22 +++++++++++++++++-- .../main/java/io/grpc/stub/ServerCalls.java | 22 +++++++++++++++---- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/stub/src/main/java/io/grpc/stub/ClientCalls.java b/stub/src/main/java/io/grpc/stub/ClientCalls.java index aa507bbd00..f946b3bcc8 100644 --- a/stub/src/main/java/io/grpc/stub/ClientCalls.java +++ b/stub/src/main/java/io/grpc/stub/ClientCalls.java @@ -59,6 +59,9 @@ public final class ClientCalls { /** * Executes a unary call with a response {@link StreamObserver}. The {@code call} should not be * already started. After calling this method, {@code call} should no longer be used. + * + *

If the provided {@code responseObserver} is an instance of {@link ClientResponseObserver}, + * {@code beforeStart()} will be called. */ public static void asyncUnaryCall( ClientCall call, ReqT req, StreamObserver responseObserver) { @@ -69,6 +72,9 @@ public final class ClientCalls { * Executes a server-streaming call with a response {@link StreamObserver}. The {@code call} * should not be already started. After calling this method, {@code call} should no longer be * used. + * + *

If the provided {@code responseObserver} is an instance of {@link ClientResponseObserver}, + * {@code beforeStart()} will be called. */ public static void asyncServerStreamingCall( ClientCall call, ReqT req, StreamObserver responseObserver) { @@ -80,7 +86,10 @@ public final class ClientCalls { * The {@code call} should not be already started. After calling this method, {@code call} * should no longer be used. * - * @return request stream observer. + *

If the provided {@code responseObserver} is an instance of {@link ClientResponseObserver}, + * {@code beforeStart()} will be called. + * + * @return request stream observer. It will extend {@link ClientCallStreamObserver} */ public static StreamObserver asyncClientStreamingCall( ClientCall call, @@ -92,7 +101,10 @@ public final class ClientCalls { * Executes a bidirectional-streaming call. The {@code call} should not be already started. * After calling this method, {@code call} should no longer be used. * - * @return request stream observer. + *

If the provided {@code responseObserver} is an instance of {@link ClientResponseObserver}, + * {@code beforeStart()} will be called. + * + * @return request stream observer. It will extend {@link ClientCallStreamObserver} */ public static StreamObserver asyncBidiStreamingCall( ClientCall call, StreamObserver responseObserver) { @@ -104,6 +116,7 @@ public final class ClientCalls { * started. After calling this method, {@code call} should no longer be used. * * @return the single response message. + * @throws StatusRuntimeException on error */ public static RespT blockingUnaryCall(ClientCall call, ReqT req) { try { @@ -120,6 +133,7 @@ public final class ClientCalls { * started. After calling this method, {@code call} should no longer be used. * * @return the single response message. + * @throws StatusRuntimeException on error */ public static RespT blockingUnaryCall( Channel channel, MethodDescriptor method, CallOptions callOptions, ReqT req) { @@ -158,6 +172,8 @@ public final class ClientCalls { * response stream. The {@code call} should not be already started. After calling this method, * {@code call} should no longer be used. * + *

The returned iterator may throw {@link StatusRuntimeException} on error. + * * @return an iterator over the response stream. */ // TODO(louiscryan): Not clear if we want to use this idiom for 'simple' stubs. @@ -173,6 +189,8 @@ public final class ClientCalls { * response stream. The {@code call} should not be already started. After calling this method, * {@code call} should no longer be used. * + *

The returned iterator may throw {@link StatusRuntimeException} on error. + * * @return an iterator over the response stream. */ // TODO(louiscryan): Not clear if we want to use this idiom for 'simple' stubs. diff --git a/stub/src/main/java/io/grpc/stub/ServerCalls.java b/stub/src/main/java/io/grpc/stub/ServerCalls.java index 8e5ed1e106..f3f8cd7470 100644 --- a/stub/src/main/java/io/grpc/stub/ServerCalls.java +++ b/stub/src/main/java/io/grpc/stub/ServerCalls.java @@ -84,22 +84,30 @@ public final class ServerCalls { /** * Adaptor to a unary call method. */ - public interface UnaryMethod extends UnaryRequestMethod {} + public interface UnaryMethod extends UnaryRequestMethod { + @Override void invoke(ReqT request, StreamObserver responseObserver); + } /** * Adaptor to a server streaming method. */ - public interface ServerStreamingMethod extends UnaryRequestMethod {} + public interface ServerStreamingMethod extends UnaryRequestMethod { + @Override void invoke(ReqT request, StreamObserver responseObserver); + } /** * Adaptor to a client streaming method. */ - public interface ClientStreamingMethod extends StreamingRequestMethod {} + public interface ClientStreamingMethod extends StreamingRequestMethod { + @Override StreamObserver invoke(StreamObserver responseObserver); + } /** * Adaptor to a bidirectional streaming method. */ - public interface BidiStreamingMethod extends StreamingRequestMethod {} + public interface BidiStreamingMethod extends StreamingRequestMethod { + @Override StreamObserver invoke(StreamObserver responseObserver); + } private static final class UnaryServerCallHandler implements ServerCallHandler { @@ -296,10 +304,16 @@ public final class ServerCalls { } private interface UnaryRequestMethod { + /** + * The provided {@code responseObserver} will extend {@link ServerCallStreamObserver}. + */ void invoke(ReqT request, StreamObserver responseObserver); } private interface StreamingRequestMethod { + /** + * The provided {@code responseObserver} will extend {@link ServerCallStreamObserver}. + */ StreamObserver invoke(StreamObserver responseObserver); }