82
82
*/
83
83
@ InternalExtensionOnly
84
84
public final class InstantiatingGrpcChannelProvider implements TransportChannelProvider {
85
- static final String DIRECT_PATH_ENV_VAR = "GOOGLE_CLOUD_ENABLE_DIRECT_PATH" ;
86
85
private static final String DIRECT_PATH_ENV_DISABLE_DIRECT_PATH =
87
86
"GOOGLE_CLOUD_DISABLE_DIRECT_PATH" ;
88
87
private static final String DIRECT_PATH_ENV_ENABLE_XDS = "GOOGLE_CLOUD_ENABLE_DIRECT_PATH_XDS" ;
@@ -237,9 +236,7 @@ private TransportChannel createChannel() throws IOException {
237
236
channelPoolSettings , InstantiatingGrpcChannelProvider .this ::createSingleChannel ));
238
237
}
239
238
240
- // TODO(mohanli): Use attemptDirectPath as the only indicator once setAttemptDirectPath is adapted
241
- // and the env var is removed from client environment.
242
- private boolean isDirectPathEnabled (String serviceAddress ) {
239
+ private boolean isDirectPathEnabled () {
243
240
String disableDirectPathEnv = envProvider .getenv (DIRECT_PATH_ENV_DISABLE_DIRECT_PATH );
244
241
boolean isDirectPathDisabled = Boolean .parseBoolean (disableDirectPathEnv );
245
242
if (isDirectPathDisabled ) {
@@ -249,16 +246,6 @@ private boolean isDirectPathEnabled(String serviceAddress) {
249
246
if (attemptDirectPath != null ) {
250
247
return attemptDirectPath ;
251
248
}
252
- // Only check DIRECT_PATH_ENV_VAR when attemptDirectPath is not set.
253
- String whiteList = envProvider .getenv (DIRECT_PATH_ENV_VAR );
254
- if (whiteList == null ) {
255
- return false ;
256
- }
257
- for (String service : whiteList .split ("," )) {
258
- if (!service .isEmpty () && serviceAddress .contains (service )) {
259
- return true ;
260
- }
261
- }
262
249
return false ;
263
250
}
264
251
@@ -318,9 +305,7 @@ private ManagedChannel createSingleChannel() throws IOException {
318
305
319
306
// Check DirectPath traffic.
320
307
boolean isDirectPathXdsEnabled = false ;
321
- if (isDirectPathEnabled (serviceAddress )
322
- && isNonDefaultServiceAccountAllowed ()
323
- && isOnComputeEngine ()) {
308
+ if (isDirectPathEnabled () && isNonDefaultServiceAccountAllowed () && isOnComputeEngine ()) {
324
309
CallCredentials callCreds = MoreCallCredentials .from (credentials );
325
310
ChannelCredentials channelCreds =
326
311
GoogleDefaultChannelCredentials .newBuilder ().callCredentials (callCreds ).build ();
0 commit comments