@@ -779,17 +779,20 @@ private CompletableFuture<AnalysisResult> schedule(String configScopeId, Analyze
779
779
schedulerCache .getOrCreateAnalysisScheduler (configScopeId , command .getTrace ()));
780
780
startChild (trace , "post" , "schedule" , () -> scheduler .post (command ));
781
781
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
- });
791
782
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
+ })
792
792
.thenApply (analysisResults -> {
793
+ if (analysisResults == null ) {
794
+ throw new CancellationException ("Analysis results should not be null" );
795
+ }
793
796
var languagePerFile = analysisResults .languagePerFile ().entrySet ().stream ().collect (HashMap <URI , SonarLanguage >::new ,
794
797
(map , entry ) -> map .put (entry .getKey ().uri (), entry .getValue ()), HashMap ::putAll );
795
798
logSummary (rawIssues , analysisResults .getDuration ());
0 commit comments