diff --git a/xds/src/main/java/io/grpc/xds/XdsClient.java b/xds/src/main/java/io/grpc/xds/XdsClient.java index 5b8072c4488..254963d2439 100644 --- a/xds/src/main/java/io/grpc/xds/XdsClient.java +++ b/xds/src/main/java/io/grpc/xds/XdsClient.java @@ -24,12 +24,12 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import io.grpc.ChannelCredentials; import io.grpc.Grpc; import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; import io.grpc.Status; import io.grpc.TlsChannelCredentials; -import io.grpc.alts.GoogleDefaultChannelBuilder; +import io.grpc.alts.GoogleDefaultChannelCredentials; import io.grpc.internal.ObjectPool; import io.grpc.xds.Bootstrapper.ChannelCreds; import io.grpc.xds.Bootstrapper.ServerInfo; @@ -620,22 +620,22 @@ XdsChannel createChannel(List servers) { String serverUri = serverInfo.getServerUri(); logger.log(XdsLogLevel.INFO, "Creating channel to {0}", serverUri); List channelCredsList = serverInfo.getChannelCredentials(); - ManagedChannelBuilder channelBuilder = null; + ChannelCredentials creds = null; // Use the first supported channel credentials configuration. // Currently, only "google_default" is supported. - for (ChannelCreds creds : channelCredsList) { - if (creds.getType().equals("google_default")) { + for (ChannelCreds credCandidate : channelCredsList) { + if (credCandidate.getType().equals("google_default")) { logger.log(XdsLogLevel.INFO, "Using channel credentials: google_default"); - channelBuilder = GoogleDefaultChannelBuilder.forTarget(serverUri); + creds = GoogleDefaultChannelCredentials.create(); break; } } - if (channelBuilder == null) { + if (creds == null) { logger.log(XdsLogLevel.INFO, "Using default channel credentials"); - channelBuilder = Grpc.newChannelBuilder(serverUri, TlsChannelCredentials.create()); + creds = TlsChannelCredentials.create(); } - ManagedChannel channel = channelBuilder + ManagedChannel channel = Grpc.newChannelBuilder(serverUri, creds) .keepAliveTime(5, TimeUnit.MINUTES) .build(); boolean useProtocolV3 = experimentalV3SupportEnvVar