Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

Commit 1b09bcf

Browse files
authored
fix: Settings objects should not try to read quotaProjectId from credentials (#1162)
* fix: defer credential loading until you ask for quotaProjectId * fix: StubSettings doesn't need to know quotaProjectId loading order * test: remove test scenario we don't care about
1 parent cbfd0a3 commit 1b09bcf

File tree

2 files changed

+0
-11
lines changed

2 files changed

+0
-11
lines changed

gax/src/main/java/com/google/api/gax/rpc/StubSettings.java

-9
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import com.google.api.gax.core.NoCredentialsProvider;
4242
import com.google.api.gax.tracing.ApiTracerFactory;
4343
import com.google.api.gax.tracing.NoopApiTracerFactory;
44-
import com.google.auth.Credentials;
4544
import com.google.auth.oauth2.QuotaProjectIdProvider;
4645
import com.google.common.base.MoreObjects;
4746
import com.google.common.base.Preconditions;
@@ -266,14 +265,6 @@ public B setExecutorProvider(ExecutorProvider executorProvider) {
266265
/** Sets the CredentialsProvider to use for getting the credentials to make calls with. */
267266
public B setCredentialsProvider(CredentialsProvider credentialsProvider) {
268267
this.credentialsProvider = Preconditions.checkNotNull(credentialsProvider);
269-
try {
270-
Credentials credentials = credentialsProvider.getCredentials();
271-
if (this.quotaProjectId == null && credentials instanceof QuotaProjectIdProvider) {
272-
this.quotaProjectId = ((QuotaProjectIdProvider) credentials).getQuotaProjectId();
273-
}
274-
} catch (IOException e) {
275-
System.out.println("fail to fetch credentials");
276-
}
277268
return self();
278269
}
279270

gax/src/test/java/com/google/api/gax/rpc/ClientSettingsTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,6 @@ public Credentials getCredentials() throws IOException {
420420
.isEqualTo(QUOTA_PROJECT_ID_FROM_INTERNAL_HEADER_VALUE);
421421
Truth.assertThat(builder_setQuotaFromInternalHeadersAndBuilders.getQuotaProjectId())
422422
.isEqualTo(QUOTA_PROJECT_ID_FROM_BUILDERS);
423-
Truth.assertThat(builder_setQuotaFromCredentialsProvider.getQuotaProjectId())
424-
.isEqualTo(QUOTA_PROJECT_ID_FROM_CREDENTIALS_VALUE);
425423
Truth.assertThat(builder_setQuotaFromCredentialsProviderAndBuilder.getQuotaProjectId())
426424
.isEqualTo(QUOTA_PROJECT_ID_FROM_BUILDERS);
427425
Truth.assertThat(builder_setQuotaFromAllSources.getQuotaProjectId())

0 commit comments

Comments
 (0)