diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Test/SonarCloudWebServerTest.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Test/SonarCloudWebServerTest.cs index d2036afe4..f201db9db 100644 --- a/Tests/SonarScanner.MSBuild.PreProcessor.Test/SonarCloudWebServerTest.cs +++ b/Tests/SonarScanner.MSBuild.PreProcessor.Test/SonarCloudWebServerTest.cs @@ -346,7 +346,8 @@ public async Task DownloadCache_ThrowException() var result = await sut.DownloadCache(localSettings); result.Should().BeEmpty(); - logger.AssertSingleDebugMessageExists("Incremental PR analysis: an error occurred while retrieving the cache entries! Found invalid data while decoding."); + logger.AssertSingleWarningExists("Incremental PR analysis: an error occurred while retrieving the cache entries! Found invalid data while decoding."); + logger.AssertNoErrorsLogged(); handler.VerifyAll(); } diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Test/SonarQubeWebServerTest.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Test/SonarQubeWebServerTest.cs index 59c7f100a..220332a11 100644 --- a/Tests/SonarScanner.MSBuild.PreProcessor.Test/SonarQubeWebServerTest.cs +++ b/Tests/SonarScanner.MSBuild.PreProcessor.Test/SonarQubeWebServerTest.cs @@ -495,7 +495,7 @@ public async Task DownloadCache_DeserializesMessage() } [TestMethod] - public async Task DownloadCache_WhenDownloadStreamReturnsNull_ReturnsEmptyAndLogsException() + public async Task DownloadCache_WhenDownloadStreamReturnsNull_ReturnsEmpty() { sut = new SonarQubeWebServer(MockIDownloader(null), version, logger, null); @@ -503,7 +503,8 @@ public async Task DownloadCache_WhenDownloadStreamReturnsNull_ReturnsEmptyAndLog var result = await sut.DownloadCache(localSettings); result.Should().BeEmpty(); - logger.AssertSingleWarningExists("Incremental PR analysis: an error occurred while retrieving the cache entries! Object reference not set to an instance of an object."); + logger.AssertNoWarningsLogged(); + logger.AssertNoErrorsLogged(); // There are no errors or warnings logs but we will display an info message in the caller: "Cache data is empty. A full analysis will be performed." } [TestMethod] diff --git a/src/SonarScanner.MSBuild.PreProcessor/WebServer/SonarCloudWebServer.cs b/src/SonarScanner.MSBuild.PreProcessor/WebServer/SonarCloudWebServer.cs index bbbce1135..52206de4c 100644 --- a/src/SonarScanner.MSBuild.PreProcessor/WebServer/SonarCloudWebServer.cs +++ b/src/SonarScanner.MSBuild.PreProcessor/WebServer/SonarCloudWebServer.cs @@ -99,7 +99,8 @@ public override async Task> DownloadCache(ProcessedArgs } catch (Exception e) { - logger.LogDebug(Resources.WARN_IncrementalPRCacheEntryRetrieval_Error, e.Message); + logger.LogWarning(Resources.WARN_IncrementalPRCacheEntryRetrieval_Error, e.Message); + logger.LogDebug(e.ToString()); return empty; } } diff --git a/src/SonarScanner.MSBuild.PreProcessor/WebServer/SonarQubeWebServer.cs b/src/SonarScanner.MSBuild.PreProcessor/WebServer/SonarQubeWebServer.cs index 59bdc1299..80096c4ad 100644 --- a/src/SonarScanner.MSBuild.PreProcessor/WebServer/SonarQubeWebServer.cs +++ b/src/SonarScanner.MSBuild.PreProcessor/WebServer/SonarQubeWebServer.cs @@ -109,6 +109,7 @@ public override async Task> DownloadCache(ProcessedArgs catch (Exception e) { logger.LogWarning(Resources.WARN_IncrementalPRCacheEntryRetrieval_Error, e.Message); + logger.LogDebug(e.ToString()); return empty; } } diff --git a/src/SonarScanner.MSBuild.PreProcessor/WebServer/SonarWebServer.cs b/src/SonarScanner.MSBuild.PreProcessor/WebServer/SonarWebServer.cs index 4c27c1b22..2dad2d1ac 100644 --- a/src/SonarScanner.MSBuild.PreProcessor/WebServer/SonarWebServer.cs +++ b/src/SonarScanner.MSBuild.PreProcessor/WebServer/SonarWebServer.cs @@ -232,6 +232,10 @@ protected bool TryGetBaseBranch(ProcessedArgs localSettings, out string branch) protected static IList ParseCacheEntries(Stream dataStream) { + if (dataStream == null) + { + return Array.Empty(); + } var cacheEntries = new List(); while (dataStream.Position < dataStream.Length) {