core: Loop over interceptors when computing effective interceptors

A post-merge review of 8516cfef9 suggested this change and the comment
had been lost in my inbox.
This commit is contained in:
Eric Anderson 2025-04-07 14:26:14 -07:00
parent 54d37839a3
commit 2db4852e23
1 changed files with 9 additions and 11 deletions

View File

@ -737,18 +737,16 @@ public final class ManagedChannelImplBuilder
// TODO(zdapeng): FIX IT
@VisibleForTesting
List<ClientInterceptor> getEffectiveInterceptors(String computedTarget) {
List<ClientInterceptor> effectiveInterceptors = new ArrayList<>(this.interceptors);
for (int i = 0; i < effectiveInterceptors.size(); i++) {
if (!(effectiveInterceptors.get(i) instanceof InterceptorFactoryWrapper)) {
continue;
List<ClientInterceptor> effectiveInterceptors = new ArrayList<>(this.interceptors.size());
for (ClientInterceptor interceptor : this.interceptors) {
if (interceptor instanceof InterceptorFactoryWrapper) {
InterceptorFactory factory = ((InterceptorFactoryWrapper) interceptor).factory;
interceptor = factory.newInterceptor(computedTarget);
if (interceptor == null) {
throw new NullPointerException("Factory returned null interceptor: " + factory);
}
}
InterceptorFactory factory =
((InterceptorFactoryWrapper) effectiveInterceptors.get(i)).factory;
ClientInterceptor interceptor = factory.newInterceptor(computedTarget);
if (interceptor == null) {
throw new NullPointerException("Factory returned null interceptor: " + factory);
}
effectiveInterceptors.set(i, interceptor);
effectiveInterceptors.add(interceptor);
}
boolean disableImplicitCensus = InternalConfiguratorRegistry.wasSetConfiguratorsCalled();