Skip to content

Commit

Permalink
Merge 'release/8.0' into release/8.0-preview7
Browse files Browse the repository at this point in the history
  • Loading branch information
joperezr committed May 1, 2024
2 parents 6bd2991 + dbcbdb7 commit 4952a6e
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ public ValueTask<ServiceEndpointSource> GetEndpointsAsync(CancellationToken canc
async ValueTask<ServiceEndpointSource> GetEndpointsInternal(CancellationToken cancellationToken)
{
ServiceEndpointSource? result;
var disposalToken = _disposalCancellation.Token;
do
{
disposalToken.ThrowIfCancellationRequested();
cancellationToken.ThrowIfCancellationRequested();
await RefreshAsync(force: false).WaitAsync(cancellationToken).ConfigureAwait(false);
result = _cachedEndpoints;
Expand Down Expand Up @@ -194,7 +196,14 @@ private async Task RefreshAsyncInternal()

if (OnEndpointsUpdated is { } callback)
{
callback(new(newEndpoints, error));
try
{
callback(new(newEndpoints, error));
}
catch (Exception exception)
{
_logger.LogError(exception, "Error notifying observers of updated endpoints.");
}
}

lock (_lock)
Expand Down Expand Up @@ -244,10 +253,17 @@ private void SchedulePollingTimer()
/// <inheritdoc/>
public async ValueTask DisposeAsync()
{
lock (_lock)
try
{
_disposalCancellation.Cancel();
}
catch (Exception exception)
{
_logger.LogError(exception, "Error cancelling disposal cancellation token.");
}

lock (_lock)
{
_changeTokenRegistration?.Dispose();
_changeTokenRegistration = null;

Expand Down

0 comments on commit 4952a6e

Please sign in to comment.