Skip to content

Commit 8e17d6e

Browse files
committed
Pass cancellation token through to semaphore wait. Use null conditional operator for max age check.
Update unit test to allow for more derived type TaskCanceledException, which is thrown by the semaphore wait.
1 parent 8176a6d commit 8e17d6e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

FirebaseAdmin/FirebaseAdmin.Tests/Auth/FirebaseAuthTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public async Task VerifyIdTokenCancel()
136136
var canceller = new CancellationTokenSource();
137137
canceller.Cancel();
138138
var idToken = await FirebaseTokenVerifierTest.CreateTestTokenAsync();
139-
await Assert.ThrowsAsync<OperationCanceledException>(
139+
await Assert.ThrowsAnyAsync<OperationCanceledException>(
140140
async () => await FirebaseAuth.DefaultInstance.VerifyIdTokenAsync(
141141
idToken, canceller.Token));
142142
}

FirebaseAdmin/FirebaseAdmin/Auth/HttpPublicKeySource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public async Task<IReadOnlyList<PublicKey>> GetPublicKeysAsync(
6868
{
6969
if (_cachedKeys == null || _clock.UtcNow >= _expirationTime)
7070
{
71-
await _lock.WaitAsync().ConfigureAwait(false);
71+
await _lock.WaitAsync(cancellationToken).ConfigureAwait(false);
7272

7373
try
7474
{
@@ -83,7 +83,7 @@ public async Task<IReadOnlyList<PublicKey>> GetPublicKeysAsync(
8383
_cachedKeys = ParseKeys(await response.Content.ReadAsStringAsync()
8484
.ConfigureAwait(false));
8585
var cacheControl = response.Headers.CacheControl;
86-
if (cacheControl != null && cacheControl.MaxAge.HasValue)
86+
if (cacheControl?.MaxAge != null)
8787
{
8888
_expirationTime = now.Add(cacheControl.MaxAge.Value)
8989
.Subtract(ClockSkew);

0 commit comments

Comments
 (0)