-
Notifications
You must be signed in to change notification settings - Fork 218
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
Retry HTTP failures in ServiceAccountCredentials.refreshAccessToken #104
Conversation
@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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@vam-google PTAL when you get a chance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Addresses #91.