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

fix connection leak on retrofit OAuth token renewal #1235

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,14 @@ public class OAuth implements Interceptor {

// 401/403 most likely indicates that access token has expired. Unless it happens two times in a row.
if ( response != null && (response.code() == HTTP_UNAUTHORIZED || response.code() == HTTP_FORBIDDEN) && updateTokenAndRetryOnAuthorizationFailure ) {
if (updateAccessToken(requestAccessToken)) {
return retryingIntercept( chain, false );
try {
if (updateAccessToken(requestAccessToken)) {
response.body().close();
return retryingIntercept( chain, false );
}
} catch (Exception e) {
response.body().close();
throw e;
}
}
return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,15 @@ public class OAuth implements Interceptor {

// 401/403 most likely indicates that access token has expired. Unless it happens two times in a row.
if ( response != null && (response.code() == HTTP_UNAUTHORIZED || response.code() == HTTP_FORBIDDEN) && updateTokenAndRetryOnAuthorizationFailure ) {
if (updateAccessToken(requestAccessToken)) {
return retryingIntercept( chain, false );
if ( response != null && (response.code() == HTTP_UNAUTHORIZED || response.code() == HTTP_FORBIDDEN) && updateTokenAndRetryOnAuthorizationFailure ) {
try {
if (updateAccessToken(requestAccessToken)) {
response.body().close();
return retryingIntercept( chain, false );
}
} catch (Exception e) {
response.body().close();
throw e;
}
}
return response;
Expand Down