Skip to content

Commit

Permalink
move it all into 1 try block.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmehta19 committed Oct 25, 2024
1 parent 7447f0b commit ed681f5
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions oauth2_http/java/com/google/auth/oauth2/S2A.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ private S2AConfig getS2AConfigFromMDS() {
ServiceLoader.load(HttpTransportFactory.class), OAuth2Utils.HTTP_TRANSPORT_FACTORY);
}

HttpRequest request;
String plaintextS2AAddress = "";
String mtlsS2AAddress = "";
try {
request = transportFactory.create().createRequestFactory().buildGetRequest(genericUrl);
HttpRequest request = transportFactory.create().createRequestFactory().buildGetRequest(genericUrl);
request.setParser(parser);
request.getHeaders().set(METADATA_FLAVOR, GOOGLE);
request.setThrowExceptionOnExecuteError(false);
Expand All @@ -158,13 +159,7 @@ private S2AConfig getS2AConfigFromMDS() {
.setBackOffRequired(
response -> RETRYABLE_STATUS_CODES.contains(response.getStatusCode())));
request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler(backoff));
} catch (IOException e) {
return S2AConfig.createBuilder().build();
}

String plaintextS2AAddress = "";
String mtlsS2AAddress = "";
try {
HttpResponse response = request.execute();
InputStream content = response.getContent();
if (content == null) {
Expand All @@ -186,6 +181,7 @@ private S2AConfig getS2AConfigFromMDS() {
/*
* Return empty addresses in {@link S2AConfig} once all retries have been exhausted.
*/
return S2AConfig.createBuilder().build();
}

return S2AConfig.createBuilder()
Expand Down

0 comments on commit ed681f5

Please sign in to comment.