mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-10-05 11:18:24 +00:00
Merge pull request #4108 from davotoula/fix/blossom-read-auth-single-flight-race
fix(blossom): re-check the token cache after winning the in-flight slot
This commit is contained in:
+11
@@ -129,6 +129,17 @@ class BlossomReadAuthTokenProvider(
|
||||
val fresh = CompletableDeferred<String?>()
|
||||
inFlight.putIfAbsent(host, fresh)?.let { return it }
|
||||
|
||||
// Third look, now that this caller owns the slot. The look above still leaves a
|
||||
// gap: a leader can insert, sign, cache and retire its entry entirely between
|
||||
// that read and the putIfAbsent, so the map is empty again and this caller wins
|
||||
// it. Any leader that retired before this insert cached first, so a token
|
||||
// present now is theirs — take it and give the slot back instead of re-signing.
|
||||
cachedHeader(host)?.let {
|
||||
inFlight.remove(host, fresh)
|
||||
fresh.complete(it)
|
||||
return fresh
|
||||
}
|
||||
|
||||
scope
|
||||
.launch {
|
||||
val header =
|
||||
|
||||
Reference in New Issue
Block a user