Skip to content

Commit 2db4852

Browse files
committed
core: Loop over interceptors when computing effective interceptors
A post-merge review of 8516cfe suggested this change and the comment had been lost in my inbox.
1 parent 54d3783 commit 2db4852

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

core/src/main/java/io/grpc/internal/ManagedChannelImplBuilder.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -737,18 +737,16 @@ public ManagedChannel build() {
737737
// TODO(zdapeng): FIX IT
738738
@VisibleForTesting
739739
List<ClientInterceptor> getEffectiveInterceptors(String computedTarget) {
740-
List<ClientInterceptor> effectiveInterceptors = new ArrayList<>(this.interceptors);
741-
for (int i = 0; i < effectiveInterceptors.size(); i++) {
742-
if (!(effectiveInterceptors.get(i) instanceof InterceptorFactoryWrapper)) {
743-
continue;
744-
}
745-
InterceptorFactory factory =
746-
((InterceptorFactoryWrapper) effectiveInterceptors.get(i)).factory;
747-
ClientInterceptor interceptor = factory.newInterceptor(computedTarget);
748-
if (interceptor == null) {
749-
throw new NullPointerException("Factory returned null interceptor: " + factory);
740+
List<ClientInterceptor> effectiveInterceptors = new ArrayList<>(this.interceptors.size());
741+
for (ClientInterceptor interceptor : this.interceptors) {
742+
if (interceptor instanceof InterceptorFactoryWrapper) {
743+
InterceptorFactory factory = ((InterceptorFactoryWrapper) interceptor).factory;
744+
interceptor = factory.newInterceptor(computedTarget);
745+
if (interceptor == null) {
746+
throw new NullPointerException("Factory returned null interceptor: " + factory);
747+
}
750748
}
751-
effectiveInterceptors.set(i, interceptor);
749+
effectiveInterceptors.add(interceptor);
752750
}
753751

754752
boolean disableImplicitCensus = InternalConfiguratorRegistry.wasSetConfiguratorsCalled();

0 commit comments

Comments
 (0)