diff --git a/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java b/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java index dc582b9d5e2..0278ce42a43 100644 --- a/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java +++ b/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java @@ -576,7 +576,7 @@ ClientStream newSubstream(ClientStreamTracer.Factory tracerFactory, Metadata new this.retryEnabled = builder.retryEnabled && !builder.temporarilyDisableRetry; serviceConfigInterceptor = new ServiceConfigInterceptor( retryEnabled, builder.maxRetryAttempts, builder.maxHedgedAttempts); - Channel channel = new RealChannel(); + Channel channel = new RealChannel(nameResolver.getServiceAuthority()); channel = ClientInterceptors.intercept(channel, serviceConfigInterceptor); if (builder.binlog != null) { channel = builder.binlog.wrapChannel(channel); @@ -810,6 +810,14 @@ private Executor getCallExecutor(CallOptions callOptions) { } private class RealChannel extends Channel { + // Set when the NameResolver is initially created. When we create a new NameResolver for the + // same target, the new instance must have the same value. + private final String authority; + + private RealChannel(String authority) { + this.authority = checkNotNull(authority, "authority"); + } + @Override public ClientCall newCall(MethodDescriptor method, CallOptions callOptions) { @@ -828,8 +836,7 @@ public ClientCall newCall(MethodDescriptor {