From 033cf21118307d20b604f1eb85c6dd61c79f3b6c Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Tue, 6 Nov 2018 07:22:51 -0800 Subject: [PATCH] core: Explicitly mention MCB.intercept's execution order New users are much more likely to use MCB to add an interceptor instead of ClientInterceptors, so may not be aware of the interesting execution order. --- core/src/main/java/io/grpc/ManagedChannelBuilder.java | 6 +++++- core/src/main/java/io/grpc/ServerBuilder.java | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/io/grpc/ManagedChannelBuilder.java b/core/src/main/java/io/grpc/ManagedChannelBuilder.java index 596c03f64b..59f4c87d6d 100644 --- a/core/src/main/java/io/grpc/ManagedChannelBuilder.java +++ b/core/src/main/java/io/grpc/ManagedChannelBuilder.java @@ -104,7 +104,9 @@ public abstract class ManagedChannelBuilder> /** * Adds interceptors that will be called before the channel performs its real work. This is * functionally equivalent to using {@link ClientInterceptors#intercept(Channel, List)}, but while - * still having access to the original {@code ManagedChannel}. + * still having access to the original {@code ManagedChannel}. Interceptors run in the reverse + * order in which they are added, just as with consecutive calls to {@code + * ClientInterceptors.intercept()}. * * @return this * @since 1.0.0 @@ -115,6 +117,8 @@ public abstract class ManagedChannelBuilder> * Adds interceptors that will be called before the channel performs its real work. This is * functionally equivalent to using {@link ClientInterceptors#intercept(Channel, * ClientInterceptor...)}, but while still having access to the original {@code ManagedChannel}. + * Interceptors run in the reverse order in which they are added, just as with consecutive calls + * to {@code ClientInterceptors.intercept()}. * * @return this * @since 1.0.0 diff --git a/core/src/main/java/io/grpc/ServerBuilder.java b/core/src/main/java/io/grpc/ServerBuilder.java index 8b3f69d297..ee1b911e76 100644 --- a/core/src/main/java/io/grpc/ServerBuilder.java +++ b/core/src/main/java/io/grpc/ServerBuilder.java @@ -94,7 +94,8 @@ public abstract class ServerBuilder> { /** * Adds a {@link ServerInterceptor} that is run for all services on the server. Interceptors * added through this method always run before per-service interceptors added through {@link - * ServerInterceptors}. Interceptors run in the reverse order in which they are added. + * ServerInterceptors}. Interceptors run in the reverse order in which they are added, just as + * with consecutive calls to {@code ServerInterceptors.intercept()}. * * @param interceptor the all-service interceptor * @return this