Skip to content

Commit

Permalink
Add explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
stoyicker committed Jun 24, 2024
1 parent 803dc73 commit b83f1b8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions auth/src/main/kotlin/com/tidal/sdk/auth/TokenRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ internal class TokenRepository(
getCredentialsCalls.incrementAndGet()
logger.d { "Received subStatus: $apiErrorSubStatus" }
val latestTokens = getLatestTokens()
/**
* Note the double if check. This is to avoid synchronized whenever possible (since it's
* slow). It's the same reason why when you write a singleton you're supposed to do the
* null check both outside and inside the synchronized call.
*/
if ((latestTokens?.credentials?.isExpired(timeProvider) != false) ||
needsCredentialsUpgrade()
) {
Expand Down

0 comments on commit b83f1b8

Please sign in to comment.