Skip to content

Commit b1044cf

Browse files
committed
chore: Propogate connect and read timeouts to all calls
1 parent 56cae6c commit b1044cf

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ ImpersonatedCredentials buildImpersonatedCredentials() {
311311
.setScopes(new ArrayList<>(scopes))
312312
.setLifetime(this.serviceAccountImpersonationOptions.lifetime)
313313
.setIamEndpointOverride(serviceAccountImpersonationUrl)
314+
.setConnectTimeout(connectTimeout)
315+
.setReadTimeout(readTimeout)
314316
.build();
315317
}
316318

@@ -539,9 +541,9 @@ protected AccessToken exchangeExternalCredentialForAccessToken(
539541

540542
StsRequestHandler.Builder requestHandler =
541543
StsRequestHandler.newBuilder(
542-
tokenUrl, stsTokenExchangeRequest, transportFactory.create().createRequestFactory());
543-
requestHandler.setConnectTimeout(connectTimeout);
544-
requestHandler.setReadTimeout(readTimeout);
544+
tokenUrl, stsTokenExchangeRequest, transportFactory.create().createRequestFactory())
545+
.setConnectTimeout(connectTimeout)
546+
.setReadTimeout(readTimeout);
545547

546548
// If this credential was initialized with a Workforce configuration then the
547549
// workforcePoolUserProject must be passed to the Security Token Service via the internal
@@ -779,8 +781,8 @@ public abstract static class Builder extends GoogleCredentials.Builder {
779781
@Nullable protected String workforcePoolUserProject;
780782
@Nullable protected ServiceAccountImpersonationOptions serviceAccountImpersonationOptions;
781783

782-
private int connectTimeout = 20000; // Default to 20000ms = 20s
783-
private int readTimeout = 20000; // Default to 20000ms = 20s
784+
protected int connectTimeout = 20000; // Default to 20000ms = 20s
785+
protected int readTimeout = 20000; // Default to 20000ms = 20s
784786

785787
/* The field is not being used and value not set. Superseded by the same field in the
786788
{@link GoogleCredentials.Builder}.

oauth2_http/java/com/google/auth/oauth2/StsRequestHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public final class StsRequestHandler {
7474
@Nullable private final HttpHeaders headers;
7575
@Nullable private final String internalOptions;
7676

77-
private int connectTimeout;
78-
private int readTimeout;
77+
private final int connectTimeout;
78+
private final int readTimeout;
7979

8080
/**
8181
* Internal constructor.

0 commit comments

Comments
 (0)