@@ -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