diff --git a/core/src/main/java/io/grpc/ClientCall.java b/core/src/main/java/io/grpc/ClientCall.java index 268b9797a1..bc0ad5142d 100644 --- a/core/src/main/java/io/grpc/ClientCall.java +++ b/core/src/main/java/io/grpc/ClientCall.java @@ -124,7 +124,8 @@ public abstract class ClientCall { /** * Start a call, using {@code responseListener} for processing response messages. * - *

It must be called prior to any other method on this class. + *

It must be called prior to any other method on this class. Since {@link Metadata} is not + * thread-safe, the caller must not access {@code headers} after this point. * * @param responseListener receives response messages * @param headers which can contain extra call metadata, e.g. authentication credentials. diff --git a/core/src/main/java/io/grpc/ServerCall.java b/core/src/main/java/io/grpc/ServerCall.java index 6e2b194003..6392470382 100644 --- a/core/src/main/java/io/grpc/ServerCall.java +++ b/core/src/main/java/io/grpc/ServerCall.java @@ -119,6 +119,9 @@ public abstract class ServerCall { * Send response header metadata prior to sending a response message. This method may * only be called once and cannot be called after calls to {@link #sendMessage} or {@link #close}. * + *

Since {@link Metadata} is not thread-safe, the caller must not access {@code headers} after + * this point. + * * @param headers metadata to send prior to any response body. * @throws IllegalStateException if {@code close} has been called, a message has been sent, or * headers have already been sent @@ -154,6 +157,9 @@ public abstract class ServerCall { * notification should be expected, independent of {@code status}. Otherwise {@link * Listener#onCancel} has been or will be called. * + *

Since {@link Metadata} is not thread-safe, the caller must not access {@code trailers} after + * this point. + * * @throws IllegalStateException if call is already {@code close}d */ public abstract void close(Status status, Metadata trailers);