Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry HTTP failures in ServiceAccountCredentials.refreshAccessToken #104

Merged
merged 3 commits into from
May 30, 2017

Conversation

tcoffee-google
Copy link
Contributor

Addresses #91.

@garrettjonesgoogle
Copy link
Member

@vam-google could you take a first look?

@@ -340,6 +343,23 @@ public AccessToken refreshAccessToken() throws IOException {
HttpRequest request = requestFactory.buildPostRequest(new GenericUrl(tokenServerUri), content);
request.setParser(new JsonObjectParser(jsonFactory));

request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler(new ExponentialBackOff()));
request.setUnsuccessfulResponseHandler(
new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff()).setBackOffRequired(

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -340,6 +343,23 @@ public AccessToken refreshAccessToken() throws IOException {
HttpRequest request = requestFactory.buildPostRequest(new GenericUrl(tokenServerUri), content);
request.setParser(new JsonObjectParser(jsonFactory));

request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler(new ExponentialBackOff()));
request.setUnsuccessfulResponseHandler(

This comment was marked as spam.

This comment was marked as spam.

int code = response.getStatusCode();
return (
// Server error --- includes timeout errors, which use 500 instead of 408
code / 100 == 5

This comment was marked as spam.

This comment was marked as spam.

@@ -241,6 +242,55 @@ public void getRequestMetadata_customTokenServer_hasAccessToken() throws IOExcep
}

@Test
public void refreshAccessToken_retries() throws IOException {

This comment was marked as spam.

This comment was marked as spam.

@tcoffee-google
Copy link
Contributor Author

@vam-google PTAL when you get a chance.

Copy link

@vam-google vam-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tcoffee-google tcoffee-google merged commit 97cf8aa into googleapis:master May 30, 2017
@tcoffee-google tcoffee-google deleted the retry_refresh_token branch May 30, 2017 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants