Skip to content

Commit

Permalink
Skip saving tokens when not changed in refresh.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Aug 24, 2023
1 parent bfda757 commit 722bcdd
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ public OAuthTokens save(final OAuthTokens tokens) throws LocalAccessDeniedExcept
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
if(tokens.isExpired()) {
try {
this.save(this.refresh(tokens));
final OAuthTokens previous = tokens;
final OAuthTokens refreshed = this.refresh(tokens);
// Skip saving tokens when not changed
if(!refreshed.equals(previous)) {
this.save(refreshed);
}
}
catch(BackgroundException e) {
log.warn(String.format("Failure %s refreshing OAuth tokens %s", e, tokens));
Expand Down

0 comments on commit 722bcdd

Please sign in to comment.