Skip to content

Commit

Permalink
oauth2_http: Use Futures.getDone() instead of Future.get() in listener (
Browse files Browse the repository at this point in the history
#1109)

Listeners for Futures should generally use Futures.addCallback() or
Futures.getDone() when called. This makes it clear they won't block and
allows tooling to know it will never block.

cl/492555987

Co-authored-by: Timur Sadykov <stim@google.com>
  • Loading branch information
ejona86 and TimurSadykov authored Jan 25, 2023
1 parent 06bf21a commit 1e624a9
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,10 @@ public OAuthValue call() throws Exception {
private void finishRefreshAsync(ListenableFuture<OAuthValue> finishedTask) {
synchronized (lock) {
try {
this.value = finishedTask.get();
this.value = Futures.getDone(finishedTask);
for (CredentialsChangedListener listener : changeListeners) {
listener.onChanged(this);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (Exception e) {
// noop
} finally {
Expand Down

0 comments on commit 1e624a9

Please sign in to comment.