diff --git a/core/src/main/java/io/grpc/LoadBalancer2.java b/core/src/main/java/io/grpc/LoadBalancer2.java index 2945efbb097..a1978b138ab 100644 --- a/core/src/main/java/io/grpc/LoadBalancer2.java +++ b/core/src/main/java/io/grpc/LoadBalancer2.java @@ -329,7 +329,17 @@ public abstract static class Helper { *
The LoadBalancer is responsible for closing unused Subchannels, and closing all * Subchannels within {@link #shutdown}. */ - public abstract Subchannel createSubchannel(EquivalentAddressGroup addrs, Attributes attrs); + public abstract Subchannel createSubchannel(EquivalentAddressGroup addrs, Attributes attrs, + String authority); + + /** + * Creates a Subchannel with the default authority of the load balancer. + * + * @see LoadBalancer2.Helper#createSubchannel(EquivalentAddressGroup, Attributes, String). + */ + public Subchannel createSubchannel(EquivalentAddressGroup addrs, Attributes attrs) { + return createSubchannel(addrs, attrs, getAuthority()); + } /** * Out-of-band channel for LoadBalancer’s own RPC needs, e.g., talking to an external diff --git a/core/src/main/java/io/grpc/internal/ManagedChannelImpl2.java b/core/src/main/java/io/grpc/internal/ManagedChannelImpl2.java index a1acaac3afe..bd475f2b9d8 100644 --- a/core/src/main/java/io/grpc/internal/ManagedChannelImpl2.java +++ b/core/src/main/java/io/grpc/internal/ManagedChannelImpl2.java @@ -600,16 +600,18 @@ private class LbHelperImpl extends LoadBalancer2.Helper { } @Override - public SubchannelImpl createSubchannel(EquivalentAddressGroup addressGroup, Attributes attrs) { + public SubchannelImpl createSubchannel(EquivalentAddressGroup addressGroup, Attributes attrs, + String authority) { checkNotNull(addressGroup, "addressGroup"); checkNotNull(attrs, "attrs"); + checkNotNull(authority, "authority"); ScheduledExecutorService scheduledExecutorCopy = scheduledExecutor; checkState(scheduledExecutorCopy != null, "scheduledExecutor is already cleared. Looks like you are calling this method after " + "you've already shut down"); final SubchannelImplImpl subchannel = new SubchannelImplImpl(attrs); final InternalSubchannel internalSubchannel = new InternalSubchannel( - addressGroup, authority(), userAgent, backoffPolicyProvider, transportFactory, + addressGroup, authority, userAgent, backoffPolicyProvider, transportFactory, scheduledExecutorCopy, stopwatchSupplier, channelExecutor, new InternalSubchannel.Callback() { // All callbacks are run in channelExecutor