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

Commit

Permalink
fix: Settings objects should not try to read quotaProjectId from cred…
Browse files Browse the repository at this point in the history
…entials (#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
  • Loading branch information
chingor13 committed Aug 7, 2020
1 parent cbfd0a3 commit 1b09bcf
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 11 deletions.
9 changes: 0 additions & 9 deletions gax/src/main/java/com/google/api/gax/rpc/StubSettings.java
Expand Up @@ -41,7 +41,6 @@
import com.google.api.gax.core.NoCredentialsProvider;
import com.google.api.gax.tracing.ApiTracerFactory;
import com.google.api.gax.tracing.NoopApiTracerFactory;
import com.google.auth.Credentials;
import com.google.auth.oauth2.QuotaProjectIdProvider;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -266,14 +265,6 @@ public B setExecutorProvider(ExecutorProvider executorProvider) {
/** Sets the CredentialsProvider to use for getting the credentials to make calls with. */
public B setCredentialsProvider(CredentialsProvider credentialsProvider) {
this.credentialsProvider = Preconditions.checkNotNull(credentialsProvider);
try {
Credentials credentials = credentialsProvider.getCredentials();
if (this.quotaProjectId == null && credentials instanceof QuotaProjectIdProvider) {
this.quotaProjectId = ((QuotaProjectIdProvider) credentials).getQuotaProjectId();
}
} catch (IOException e) {
System.out.println("fail to fetch credentials");
}
return self();
}

Expand Down
Expand Up @@ -420,8 +420,6 @@ public Credentials getCredentials() throws IOException {
.isEqualTo(QUOTA_PROJECT_ID_FROM_INTERNAL_HEADER_VALUE);
Truth.assertThat(builder_setQuotaFromInternalHeadersAndBuilders.getQuotaProjectId())
.isEqualTo(QUOTA_PROJECT_ID_FROM_BUILDERS);
Truth.assertThat(builder_setQuotaFromCredentialsProvider.getQuotaProjectId())
.isEqualTo(QUOTA_PROJECT_ID_FROM_CREDENTIALS_VALUE);
Truth.assertThat(builder_setQuotaFromCredentialsProviderAndBuilder.getQuotaProjectId())
.isEqualTo(QUOTA_PROJECT_ID_FROM_BUILDERS);
Truth.assertThat(builder_setQuotaFromAllSources.getQuotaProjectId())
Expand Down

0 comments on commit 1b09bcf

Please sign in to comment.