From 9eb27bd787b9f3542ac7c0e0c6cf3557ab4ba7f7 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Fri, 12 Jul 2019 15:50:18 -0500 Subject: [PATCH] caller of GetAsStreamAsync() should handle disposal of Stream, HttpResponseMessage doesn't necessarily need disposing itself --- src/FilterLists.Agent/Infrastructure/ListRepository.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/FilterLists.Agent/Infrastructure/ListRepository.cs b/src/FilterLists.Agent/Infrastructure/ListRepository.cs index 137620392..4c2faa7cb 100644 --- a/src/FilterLists.Agent/Infrastructure/ListRepository.cs +++ b/src/FilterLists.Agent/Infrastructure/ListRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Net.Http; using System.Net.Http.Headers; @@ -27,9 +28,10 @@ public ListRepository(HttpClient httpClient, ILogger logger) _logger = logger; } + [SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope")] public async Task GetAsStreamAsync(Uri url, CancellationToken cancellationToken) { - using var response = await _httpClient.GetAsync(url, cancellationToken); + var response = await _httpClient.GetAsync(url, cancellationToken); if (response.IsSuccessStatusCode) return await response.Content.ReadAsStreamAsync(); _logger.LogError($"Error downloading list from {url}. {response.StatusCode}");