]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6014 Execute resource persister before decorator phase to fix issue with views
authorJulien HENRY <julien.henry@sonarsource.com>
Mon, 12 Jan 2015 20:31:46 +0000 (21:31 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Tue, 13 Jan 2015 13:13:55 +0000 (14:13 +0100)
sonar-batch/src/main/java/org/sonar/batch/phases/DefaultPhaseExecutor.java
sonar-batch/src/test/java/org/sonar/batch/phases/DefaultPhaseExecutorTest.java

index cf2dfa308c5e0d7a69c05a1375fea1199e63d2f6..62718b8b97eea362c7310da31332b7a434902468 100644 (file)
@@ -28,6 +28,7 @@ import org.sonar.batch.bootstrap.AnalysisMode;
 import org.sonar.batch.events.BatchStepEvent;
 import org.sonar.batch.events.EventBus;
 import org.sonar.batch.index.DefaultIndex;
+import org.sonar.batch.index.ResourcePersister;
 import org.sonar.batch.index.ScanPersister;
 import org.sonar.batch.issue.ignore.scanner.IssueExclusionsLoader;
 import org.sonar.batch.report.PublishReportJob;
@@ -66,6 +67,7 @@ public final class DefaultPhaseExecutor implements PhaseExecutor {
   private final IssueExclusionsLoader issueExclusionsLoader;
   private final AnalysisMode analysisMode;
   private final DatabaseSession session;
+  private final ResourcePersister resourcePersister;
 
   public DefaultPhaseExecutor(Phases phases, DecoratorsExecutor decoratorsExecutor,
     MavenPluginsConfigurator mavenPluginsConfigurator, InitializersExecutor initializersExecutor,
@@ -73,7 +75,7 @@ public final class DefaultPhaseExecutor implements PhaseExecutor {
     SensorContext sensorContext, DefaultIndex index,
     EventBus eventBus, PublishReportJob publishReportJob, ProjectInitializer pi,
     ScanPersister[] persisters, FileSystemLogger fsLogger, JsonReport jsonReport, DefaultModuleFileSystem fs, QProfileVerifier profileVerifier,
-    IssueExclusionsLoader issueExclusionsLoader, AnalysisMode analysisMode, DatabaseSession session) {
+    IssueExclusionsLoader issueExclusionsLoader, AnalysisMode analysisMode, DatabaseSession session, ResourcePersister resourcePersister) {
     this.phases = phases;
     this.decoratorsExecutor = decoratorsExecutor;
     this.mavenPluginsConfigurator = mavenPluginsConfigurator;
@@ -93,6 +95,7 @@ public final class DefaultPhaseExecutor implements PhaseExecutor {
     this.issueExclusionsLoader = issueExclusionsLoader;
     this.analysisMode = analysisMode;
     this.session = session;
+    this.resourcePersister = resourcePersister;
   }
 
   /**
@@ -123,6 +126,9 @@ public final class DefaultPhaseExecutor implements PhaseExecutor {
       sensorsExecutor.execute(sensorContext);
     }
 
+    // Special case for views. ProjectCountDecorator need resource id...
+    resourcePersister.persist();
+
     if (phases.isEnabled(Phases.Phase.DECORATOR)) {
       decoratorsExecutor.execute();
     }
index b88413bdc050d0b247116c7c8eefc4a6131a30eb..740a318201fa6d4090b1c0ef5915ea8b270a26f9 100644 (file)
@@ -17,17 +17,17 @@ public class DefaultPhaseExecutorTest {
     ResourcePersister resourcePersister = new ResourcePersister(null, null, null, null, null);
     ScanPersister[] persisters = new ScanPersister[] {otherPersister, measurePersister, resourcePersister};
     DefaultPhaseExecutor executor = new DefaultPhaseExecutor(null, null, null, null, null, null,
-      null, null, null, null, null, persisters, null, null, null, null, null, null, null);
+      null, null, null, null, null, persisters, null, null, null, null, null, null, null, null);
     assertThat(executor.sortedPersisters()).containsSubsequence(resourcePersister, measurePersister);
 
     persisters = new ScanPersister[] {measurePersister, resourcePersister, otherPersister};
     executor = new DefaultPhaseExecutor(null, null, null, null, null, null,
-      null, null, null, null, null, persisters, null, null, null, null, null, null, null);
+      null, null, null, null, null, persisters, null, null, null, null, null, null, null, null);
     assertThat(executor.sortedPersisters()).containsSubsequence(resourcePersister, measurePersister);
 
     persisters = new ScanPersister[] {measurePersister, otherPersister, resourcePersister};
     executor = new DefaultPhaseExecutor(null, null, null, null, null, null,
-      null, null, null, null, null, persisters, null, null, null, null, null, null, null);
+      null, null, null, null, null, persisters, null, null, null, null, null, null, null, null);
     assertThat(executor.sortedPersisters()).containsSubsequence(resourcePersister, measurePersister);
   }