Skip to content

Commit

Permalink
Fix race condition in test.
Browse files Browse the repository at this point in the history
  • Loading branch information
clundin25 committed Sep 29, 2022
1 parent b87c13f commit 4434bc4
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,12 @@ public AccessToken refreshAccessToken() {
creds.getRequestMetadata(CALL_URI, realExecutor, callback);
TestUtils.assertContainsBearerToken(callback.awaitResult(), refreshedToken.getTokenValue());

// Sleep this thread to give the refresh task a chance to complete.
// If this test is flaky consider increasing the sleep time.
// 10 is selected because simply sleeping should yield control to the refresh task (If it is
// still running).
Thread.sleep(10);

// The refresh slot should be cleared
synchronized (creds.lock) {
assertNull(creds.refreshTask);
Expand Down

0 comments on commit 4434bc4

Please sign in to comment.