]> source.dussan.org Git - sonarqube.git/commitdiff
Fix NPE when using ProjectBuilder + sonar.showProfilingLevel=true
authorJulien HENRY <julien.henry@sonarsource.com>
Tue, 2 Jun 2015 13:52:17 +0000 (15:52 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Tue, 2 Jun 2015 13:52:54 +0000 (15:52 +0200)
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectBuildersExecutor.java

index ac15206c6f3ba613da0149ec64f8b6107d37cf9e..1a43bcac39a31bd117e2eee3135828fa32be6345 100644 (file)
@@ -22,35 +22,33 @@ package org.sonar.batch.scan;
 import org.sonar.api.batch.bootstrap.ProjectBuilder;
 import org.sonar.api.batch.bootstrap.ProjectReactor;
 import org.sonar.api.batch.bootstrap.internal.ProjectBuilderContext;
-import org.sonar.batch.events.BatchStepEvent;
-import org.sonar.batch.events.EventBus;
-
-import javax.annotation.Nullable;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+import org.sonar.api.utils.log.Profiler;
 
 public class ProjectBuildersExecutor {
 
+  private static final Logger LOG = Loggers.get(ProjectBuildersExecutor.class);
+
   private final ProjectBuilder[] projectBuilders;
-  private final EventBus eventBus;
 
-  public ProjectBuildersExecutor(EventBus eventBus, @Nullable ProjectBuilder... projectBuilders) {
-    this.eventBus = eventBus;
+  public ProjectBuildersExecutor(ProjectBuilder... projectBuilders) {
     this.projectBuilders = projectBuilders;
   }
 
-  public ProjectBuildersExecutor(EventBus eventBus) {
-    this(eventBus, new ProjectBuilder[0]);
+  public ProjectBuildersExecutor() {
+    this(new ProjectBuilder[0]);
   }
 
   public void execute(ProjectReactor reactor) {
     if (projectBuilders.length > 0) {
-      String stepName = "Execute project builders";
-      eventBus.fireEvent(new BatchStepEvent(stepName, true));
+      Profiler profiler = Profiler.create(LOG).startInfo("Execute project builders");
       ProjectBuilderContext context = new ProjectBuilderContext(reactor);
 
       for (ProjectBuilder projectBuilder : projectBuilders) {
         projectBuilder.build(context);
       }
-      eventBus.fireEvent(new BatchStepEvent(stepName, false));
+      profiler.stopInfo();
     }
   }
 }