Skip to content

Commit 0ca9541

Browse files
authored
fix: add env var to allow disabling directpath bound token (#4189)
1 parent abba0c1 commit 0ca9541

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,12 @@ public GapicSpannerRpc(final SpannerOptions options) {
368368
boolean isEnableDirectAccess = options.isEnableDirectAccess();
369369
if (isEnableDirectAccess) {
370370
defaultChannelProviderBuilder.setAttemptDirectPath(true);
371-
// This will let the credentials try to fetch a hard-bound access token if the runtime
372-
// environment supports it.
373-
defaultChannelProviderBuilder.setAllowHardBoundTokenTypes(
374-
Collections.singletonList(InstantiatingGrpcChannelProvider.HardBoundTokenTypes.ALTS));
371+
if (isEnableDirectPathBoundToken()) {
372+
// This will let the credentials try to fetch a hard-bound access token if the runtime
373+
// environment supports it.
374+
defaultChannelProviderBuilder.setAllowHardBoundTokenTypes(
375+
Collections.singletonList(InstantiatingGrpcChannelProvider.HardBoundTokenTypes.ALTS));
376+
}
375377
defaultChannelProviderBuilder.setAttemptDirectPathXds();
376378
}
377379

@@ -687,6 +689,10 @@ public static boolean isEnableDirectPathXdsEnv() {
687689
return Boolean.parseBoolean(System.getenv("GOOGLE_SPANNER_ENABLE_DIRECT_ACCESS"));
688690
}
689691

692+
public static boolean isEnableDirectPathBoundToken() {
693+
return !Boolean.parseBoolean(System.getenv("GOOGLE_SPANNER_DISABLE_DIRECT_ACCESS_BOUND_TOKEN"));
694+
}
695+
690696
private static final RetrySettings ADMIN_REQUESTS_LIMIT_EXCEEDED_RETRY_SETTINGS =
691697
RetrySettings.newBuilder()
692698
.setInitialRetryDelayDuration(Duration.ofSeconds(5L))

0 commit comments

Comments
 (0)