Skip to content

Commit

Permalink
FIx sonar cloud reported bugs to dispose CTS
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Chang <[email protected]>
  • Loading branch information
mocsharp committed Jan 5, 2024
1 parent 42f3ed4 commit 63e76ed
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/DicomWebClient/CLI/Stow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
namespace Monai.Deploy.InformaticsGateway.DicomWeb.Client.CLI
{
[Command("stow", "Use stow to store DICOM instances to a remote DICOMweb server.")]
public class Stow : ConsoleAppBase
public class Stow : ConsoleAppBase, IDisposable
{
private readonly IDicomWebClient _dicomWebClient;
private readonly ILogger<Stow> _logger;
Expand Down Expand Up @@ -138,5 +138,10 @@ private void ValidateOptions(string rootUrl, out Uri rootUri)
rootUri = new Uri(rootUrl);
rootUri = rootUri.EnsureUriEndsWithSlash();
}

public void Dispose()
{
_cancellationTokeSource.Dispose();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
_cancellationTokenSource.Dispose();

Check warning on line 324 in src/InformaticsGateway/Services/Connectors/PayloadNotificationService.cs

View check run for this annotation

Codecov / codecov/patch

src/InformaticsGateway/Services/Connectors/PayloadNotificationService.cs#L324

Added line #L324 was not covered by tests
_scope.Dispose();
}

Expand Down
2 changes: 1 addition & 1 deletion src/InformaticsGateway/Services/Scu/ScuService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private Task BackgroundProcessing(CancellationToken cancellationToken)
{
var item = _workQueue.Dequeue(cancellationToken);

var linkedCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, item.CancellationToken);
using var linkedCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, item.CancellationToken);

ProcessThread(item, linkedCancellationToken.Token);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private async Task<bool> VerifyExists(string path, CancellationToken cancellatio
})
.ExecuteAsync(async () =>
{
var internalCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
using var internalCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
internalCancellationTokenSource.CancelAfter(_configuration.Value.Storage.StorageServiceListTimeout);
var exists = await _storageService.VerifyObjectExistsAsync(_configuration.Value.Storage.StorageServiceBucketName, path).ConfigureAwait(false);
_logger.VerifyFileExists(path, exists);
Expand Down Expand Up @@ -268,6 +268,7 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
_cancellationTokenSource.Dispose();
_scope.Dispose();
}

Expand Down

0 comments on commit 63e76ed

Please sign in to comment.