Skip to content

Commit

Permalink
Fix sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
adams85 committed Jul 31, 2024
1 parent 85bb5fe commit 1548e0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/ConfigCatClient/ConfigService/DefaultConfigFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ private static Uri ReplaceUri(Uri oldUri, Uri newUri)

public void Dispose()
{
this.cancellationTokenSource.Cancel();
if (!this.cancellationTokenSource.IsCancellationRequested)
{
try { this.cancellationTokenSource.Cancel(); }
catch (ObjectDisposedException) { /* intentional no-op */ }
}
this.cancellationTokenSource.Dispose();
this.configFetcher.Dispose();
}

Expand Down
12 changes: 6 additions & 6 deletions src/ConfigCatClient/Override/LocalFileDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ private async Task ReloadFileAsync(bool isAsync, CancellationToken cancellationT
this.fileLastWriteTime = File.GetLastWriteTimeUtc(this.fullPath);
}

internal void StopWatch()
{
this.cancellationTokenSource.Cancel();
}

public void Dispose()
{
// Background work should stop under all circumstances
this.cancellationTokenSource.Cancel();
if (!this.cancellationTokenSource.IsCancellationRequested)
{
try { this.cancellationTokenSource.Cancel(); }
catch (ObjectDisposedException) { /* intentional no-op */ }
}
this.cancellationTokenSource.Dispose();
}

internal sealed class SimplifiedConfig
Expand Down

0 comments on commit 1548e0d

Please sign in to comment.