Skip to content

Commit dbf4bbe

Browse files
SLCORE-1427 Noisy analysis cancellation
1 parent 2b36a82 commit dbf4bbe

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

backend/core/src/main/java/org/sonarsource/sonarlint/core/analysis/AnalysisService.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -779,17 +779,20 @@ private CompletableFuture<AnalysisResult> schedule(String configScopeId, Analyze
779779
schedulerCache.getOrCreateAnalysisScheduler(configScopeId, command.getTrace()));
780780
startChild(trace, "post", "schedule", () -> scheduler.post(command));
781781
var result = command.getFutureResult();
782-
result.exceptionally(exception -> {
783-
eventPublisher.publishEvent(new AnalysisFailedEvent(analysisId));
784-
if (exception instanceof CancellationException) {
785-
LOG.debug("Analysis canceled");
786-
} else {
787-
LOG.error("Error during analysis", exception);
788-
}
789-
return null;
790-
});
791782
return result
783+
.exceptionally(exception -> {
784+
eventPublisher.publishEvent(new AnalysisFailedEvent(analysisId));
785+
if (exception instanceof CancellationException) {
786+
LOG.debug("Analysis canceled");
787+
} else {
788+
LOG.error("Error during analysis", exception);
789+
}
790+
return null;
791+
})
792792
.thenApply(analysisResults -> {
793+
if (analysisResults == null) {
794+
throw new CancellationException("Analysis results should not be null");
795+
}
793796
var languagePerFile = analysisResults.languagePerFile().entrySet().stream().collect(HashMap<URI, SonarLanguage>::new,
794797
(map, entry) -> map.put(entry.getKey().uri(), entry.getValue()), HashMap::putAll);
795798
logSummary(rawIssues, analysisResults.getDuration());

0 commit comments

Comments
 (0)