Skip to content

Commit 5cc58aa

Browse files
authored
chore(auth): Revert temporary configurable timeout values (#12910)
Introduced in googleapis/google-auth-library-java#1847, this was temporary configurable timeout values for b/461522544 intended to unblock certain customers. However, it does not seem to have resolved the root issue and I am reverting this change.
1 parent 2e03d84 commit 5cc58aa

3 files changed

Lines changed: 1 addition & 93 deletions

File tree

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

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import com.google.api.client.http.HttpHeaders;
3737
import com.google.api.client.json.GenericJson;
3838
import com.google.api.client.util.Data;
39-
import com.google.api.core.InternalApi;
4039
import com.google.auth.RequestMetadataCallback;
4140
import com.google.auth.http.HttpTransportFactory;
4241
import com.google.common.base.MoreObjects;
@@ -99,9 +98,6 @@ public abstract class ExternalAccountCredentials extends GoogleCredentials {
9998
private EnvironmentProvider environmentProvider;
10099
private PropertyProvider propertyProvider;
101100

102-
private int connectTimeout;
103-
private int readTimeout;
104-
105101
/**
106102
* Constructor with minimum identifying information and custom HTTP transport. Does not support
107103
* workforce credentials.
@@ -281,8 +277,6 @@ protected ExternalAccountCredentials(ExternalAccountCredentials.Builder builder)
281277
: builder.metricsHandler;
282278

283279
this.name = GoogleCredentialsInfo.EXTERNAL_ACCOUNT_CREDENTIALS.getCredentialName();
284-
this.connectTimeout = builder.connectTimeout;
285-
this.readTimeout = builder.readTimeout;
286280
}
287281

288282
ImpersonatedCredentials buildImpersonatedCredentials() {
@@ -317,8 +311,6 @@ ImpersonatedCredentials buildImpersonatedCredentials() {
317311
.setScopes(new ArrayList<>(scopes))
318312
.setLifetime(this.serviceAccountImpersonationOptions.lifetime)
319313
.setIamEndpointOverride(serviceAccountImpersonationUrl)
320-
.setConnectTimeout(connectTimeout)
321-
.setReadTimeout(readTimeout)
322314
.build();
323315
}
324316

@@ -547,9 +539,7 @@ protected AccessToken exchangeExternalCredentialForAccessToken(
547539

548540
StsRequestHandler.Builder requestHandler =
549541
StsRequestHandler.newBuilder(
550-
tokenUrl, stsTokenExchangeRequest, transportFactory.create().createRequestFactory())
551-
.setConnectTimeout(connectTimeout)
552-
.setReadTimeout(readTimeout);
542+
tokenUrl, stsTokenExchangeRequest, transportFactory.create().createRequestFactory());
553543

554544
// If this credential was initialized with a Workforce configuration then the
555545
// workforcePoolUserProject must be passed to the Security Token Service via the internal
@@ -792,9 +782,6 @@ public abstract static class Builder extends GoogleCredentials.Builder {
792782
@Nullable protected String workforcePoolUserProject;
793783
@Nullable protected ServiceAccountImpersonationOptions serviceAccountImpersonationOptions;
794784

795-
protected int connectTimeout = 20000; // Default to 20000ms = 20s
796-
protected int readTimeout = 20000; // Default to 20000ms = 20s
797-
798785
/* The field is not being used and value not set. Superseded by the same field in the
799786
{@link GoogleCredentials.Builder}.
800787
*/
@@ -821,8 +808,6 @@ protected Builder(ExternalAccountCredentials credentials) {
821808
this.workforcePoolUserProject = credentials.workforcePoolUserProject;
822809
this.serviceAccountImpersonationOptions = credentials.serviceAccountImpersonationOptions;
823810
this.metricsHandler = credentials.metricsHandler;
824-
this.connectTimeout = credentials.connectTimeout;
825-
this.readTimeout = credentials.readTimeout;
826811
}
827812

828813
/**
@@ -1015,20 +1000,6 @@ public Builder setUniverseDomain(String universeDomain) {
10151000
return this;
10161001
}
10171002

1018-
/** Warning: Not for public use and can be removed at any time. */
1019-
@InternalApi
1020-
public Builder setConnectTimeout(int connectTimeout) {
1021-
this.connectTimeout = connectTimeout;
1022-
return this;
1023-
}
1024-
1025-
/** Warning: Not for public use and can be removed at any time. */
1026-
@InternalApi
1027-
public Builder setReadTimeout(int readTimeout) {
1028-
this.readTimeout = readTimeout;
1029-
return this;
1030-
}
1031-
10321003
/**
10331004
* Sets the optional Environment Provider.
10341005
*

google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import com.google.api.client.json.GenericJson;
4545
import com.google.api.client.json.JsonObjectParser;
4646
import com.google.api.client.util.GenericData;
47-
import com.google.api.core.InternalApi;
4847
import com.google.api.core.ObsoleteApi;
4948
import com.google.auth.CredentialTypeForMetrics;
5049
import com.google.auth.ServiceAccountSigner;
@@ -118,9 +117,6 @@ public class ImpersonatedCredentials extends GoogleCredentials
118117

119118
private transient Calendar calendar;
120119

121-
private int connectTimeout;
122-
private int readTimeout;
123-
124120
/**
125121
* @param sourceCredentials the source credential used to acquire the impersonated credentials. It
126122
* should be either a user account credential or a service account credential.
@@ -567,8 +563,6 @@ private ImpersonatedCredentials(Builder builder) throws IOException {
567563
+ "does not match %s universe domain set for impersonated credentials.",
568564
this.sourceCredentials.getUniverseDomain(), builder.getUniverseDomain()));
569565
}
570-
this.connectTimeout = builder.connectTimeout;
571-
this.readTimeout = builder.readTimeout;
572566
}
573567

574568
/**
@@ -597,12 +591,6 @@ public AccessToken refreshAccessToken() throws IOException {
597591
|| (isDefaultUniverseDomain()
598592
&& ((ServiceAccountCredentials) this.sourceCredentials)
599593
.shouldUseAssertionFlowForGdu())) {
600-
if (this.sourceCredentials instanceof IdentityPoolCredentials) {
601-
this.sourceCredentials =
602-
((IdentityPoolCredentials) this.sourceCredentials)
603-
.toBuilder().setConnectTimeout(connectTimeout).setReadTimeout(readTimeout).build();
604-
}
605-
606594
try {
607595
this.sourceCredentials.refreshIfExpired();
608596
} catch (IOException e) {
@@ -635,8 +623,6 @@ public AccessToken refreshAccessToken() throws IOException {
635623
// Disable automatic logging by google-http-java-client to prevent leakage of sensitive tokens.
636624
// Client Library Debug Logging via LoggingUtils is used instead.
637625
request.setLoggingEnabled(false);
638-
request.setConnectTimeout(connectTimeout);
639-
request.setReadTimeout(readTimeout);
640626
adapter.initialize(request);
641627
request.setParser(parser);
642628
MetricsUtils.setMetricsHeader(
@@ -783,9 +769,6 @@ public static class Builder extends GoogleCredentials.Builder {
783769
private String iamEndpointOverride;
784770
private Calendar calendar = Calendar.getInstance();
785771

786-
private int connectTimeout = 20000; // Default to 20000ms = 20s
787-
private int readTimeout = 20000; // Default to 20000ms = 20s
788-
789772
protected Builder() {}
790773

791774
/**
@@ -809,8 +792,6 @@ protected Builder(ImpersonatedCredentials credentials) {
809792
this.lifetime = credentials.lifetime;
810793
this.transportFactory = credentials.transportFactory;
811794
this.iamEndpointOverride = credentials.iamEndpointOverride;
812-
this.connectTimeout = credentials.connectTimeout;
813-
this.readTimeout = credentials.readTimeout;
814795
}
815796

816797
@CanIgnoreReturnValue
@@ -912,20 +893,6 @@ public Builder setCalendar(Calendar calendar) {
912893
return this;
913894
}
914895

915-
/** Warning: Not for public use and can be removed at any time. */
916-
@InternalApi
917-
public Builder setConnectTimeout(int connectTimeout) {
918-
this.connectTimeout = connectTimeout;
919-
return this;
920-
}
921-
922-
/** Warning: Not for public use and can be removed at any time. */
923-
@InternalApi
924-
public Builder setReadTimeout(int readTimeout) {
925-
this.readTimeout = readTimeout;
926-
return this;
927-
}
928-
929896
/**
930897
* This method is marked obsolete. There is no alternative to getting a custom calendar for the
931898
* Credential.

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

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import com.google.api.client.json.JsonObjectParser;
4343
import com.google.api.client.json.JsonParser;
4444
import com.google.api.client.util.GenericData;
45-
import com.google.api.core.InternalApi;
4645
import com.google.common.base.Joiner;
4746
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4847
import java.io.IOException;
@@ -77,22 +76,12 @@ public final class StsRequestHandler {
7776
@Nullable private final HttpHeaders headers;
7877
@Nullable private final String internalOptions;
7978

80-
private final int connectTimeout;
81-
private final int readTimeout;
82-
83-
/**
84-
* Internal constructor.
85-
*
86-
* @return an StsTokenExchangeResponse instance if the request was successful
87-
*/
8879
private StsRequestHandler(Builder builder) {
8980
this.tokenExchangeEndpoint = builder.tokenExchangeEndpoint;
9081
this.request = builder.request;
9182
this.httpRequestFactory = builder.httpRequestFactory;
9283
this.headers = builder.headers;
9384
this.internalOptions = builder.internalOptions;
94-
this.connectTimeout = builder.connectTimeout;
95-
this.readTimeout = builder.readTimeout;
9685
}
9786

9887
/**
@@ -125,8 +114,6 @@ public StsTokenExchangeResponse exchangeToken() throws IOException {
125114
if (headers != null) {
126115
httpRequest.setHeaders(headers);
127116
}
128-
httpRequest.setConnectTimeout(connectTimeout);
129-
httpRequest.setReadTimeout(readTimeout);
130117

131118
try {
132119
LoggingUtils.logRequest(httpRequest, LOGGER_PROVIDER, "Sending request for token exchange");
@@ -225,9 +212,6 @@ public static class Builder {
225212
@Nullable private HttpHeaders headers;
226213
@Nullable private String internalOptions;
227214

228-
private int connectTimeout = 20000; // Default to 20000ms = 20s
229-
private int readTimeout = 20000; // Default to 20000ms = 20s
230-
231215
private Builder(
232216
String tokenExchangeEndpoint,
233217
StsTokenExchangeRequest stsTokenExchangeRequest,
@@ -249,20 +233,6 @@ public StsRequestHandler.Builder setInternalOptions(String internalOptions) {
249233
return this;
250234
}
251235

252-
/** Warning: Not for public use and can be removed at any time. */
253-
@InternalApi
254-
public StsRequestHandler.Builder setConnectTimeout(int connectTimeout) {
255-
this.connectTimeout = connectTimeout;
256-
return this;
257-
}
258-
259-
/** Warning: Not for public use and can be removed at any time. */
260-
@InternalApi
261-
public StsRequestHandler.Builder setReadTimeout(int readTimeout) {
262-
this.readTimeout = readTimeout;
263-
return this;
264-
}
265-
266236
public StsRequestHandler build() {
267237
return new StsRequestHandler(this);
268238
}

0 commit comments

Comments
 (0)