aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-10-29 21:46:28 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2014-10-29 21:46:28 +0100
commitd00874c660c7c4a3ac1964220b83cd475a653c3f (patch)
tree924e694d316d85023d265fd4cdd2881eb460700d
parent9b7bcaaf80d652e92d9326367952e7ede77bd44b (diff)
downloadsonarqube-d00874c660c7c4a3ac1964220b83cd475a653c3f.tar.gz
sonarqube-d00874c660c7c4a3ac1964220b83cd475a653c3f.zip
SONAR-5375 Minor optimization to remove all issues once for a given component
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java23
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/IssueCache.java5
2 files changed, 16 insertions, 12 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java
index f46e87baf76..27ee9a8ca6f 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java
@@ -25,7 +25,12 @@ import com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.batch.*;
+import org.sonar.api.batch.Decorator;
+import org.sonar.api.batch.DecoratorBarriers;
+import org.sonar.api.batch.DecoratorContext;
+import org.sonar.api.batch.DependedUpon;
+import org.sonar.api.batch.DependsUpon;
+import org.sonar.api.batch.SonarIndex;
import org.sonar.api.component.ResourcePerspectives;
import org.sonar.api.issue.Issuable;
import org.sonar.api.issue.Issue;
@@ -69,13 +74,13 @@ public class IssueTrackingDecorator implements Decorator {
private final RuleFinder ruleFinder;
public IssueTrackingDecorator(IssueCache issueCache, InitialOpenIssuesStack initialOpenIssues, IssueTracking tracking,
- LastSnapshots lastSnapshots, SonarIndex index,
- IssueHandlers handlers, IssueWorkflow workflow,
- IssueUpdater updater,
- Project project,
- ResourcePerspectives perspectives,
- RulesProfile rulesProfile,
- RuleFinder ruleFinder) {
+ LastSnapshots lastSnapshots, SonarIndex index,
+ IssueHandlers handlers, IssueWorkflow workflow,
+ IssueUpdater updater,
+ Project project,
+ ResourcePerspectives perspectives,
+ RulesProfile rulesProfile,
+ RuleFinder ruleFinder) {
this.issueCache = issueCache;
this.initialOpenIssues = initialOpenIssues;
this.tracking = tracking;
@@ -107,9 +112,9 @@ public class IssueTrackingDecorator implements Decorator {
void doDecorate(Resource resource) {
Collection<DefaultIssue> issues = Lists.newArrayList();
for (Issue issue : issueCache.byComponent(resource.getEffectiveKey())) {
- issueCache.remove(issue);
issues.add((DefaultIssue) issue);
}
+ issueCache.removeAll(resource.getEffectiveKey());
// issues = all the issues created by rule engines during this module scan and not excluded by filters
// all the issues that are not closed in db before starting this module scan, including manual issues
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/IssueCache.java b/sonar-batch/src/main/java/org/sonar/batch/issue/IssueCache.java
index b0d56d5957d..7fd894bca6e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/IssueCache.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/IssueCache.java
@@ -20,7 +20,6 @@
package org.sonar.batch.issue;
import org.sonar.api.BatchComponent;
-import org.sonar.api.issue.Issue;
import org.sonar.api.issue.internal.DefaultIssue;
import org.sonar.batch.index.Cache;
import org.sonar.batch.index.Caches;
@@ -50,7 +49,7 @@ public class IssueCache implements BatchComponent {
return this;
}
- public boolean remove(Issue issue) {
- return cache.remove(issue.componentKey(), issue.key());
+ public boolean removeAll(String componentKey) {
+ return cache.remove(componentKey);
}
}