aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-05-05 10:30:57 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-05-05 10:31:32 +0200
commit2f5b0feb9cb79fd885f3f557ea441e92b4bb3eaf (patch)
tree1ff087cef3dff2f8787b5682766b9e5542c7f079 /sonar-batch
parent592c1cbd3a87f7b94e3749e2200b68d73ff005f4 (diff)
downloadsonarqube-2f5b0feb9cb79fd885f3f557ea441e92b4bb3eaf.tar.gz
sonarqube-2f5b0feb9cb79fd885f3f557ea441e92b4bb3eaf.zip
Fix SnapshotCache to not contains libraries.
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/SnapshotCache.java4
2 files changed, 8 insertions, 1 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java
index a904bdd4d6b..1e6f9d8af48 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java
@@ -78,7 +78,10 @@ public final class DefaultResourcePersister implements ResourcePersister {
if (snapshot != null) {
snapshotsByResource.put(resource, snapshot);
resourceCache.add(resource);
- snapshotCache.put(resource.getEffectiveKey(), snapshot);
+ if (!(resource instanceof Library)) {
+ // Maven libraries can have the same effective key than a project so we can't cache by effectiveKey
+ snapshotCache.put(resource.getEffectiveKey(), snapshot);
+ }
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/SnapshotCache.java b/sonar-batch/src/main/java/org/sonar/batch/index/SnapshotCache.java
index 8bc6d2ad83e..6e21c2d2200 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/SnapshotCache.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/SnapshotCache.java
@@ -22,10 +22,14 @@ package org.sonar.batch.index;
import com.google.common.collect.Maps;
import org.sonar.api.BatchComponent;
import org.sonar.api.database.model.Snapshot;
+import org.sonar.api.resources.Library;
import java.util.Map;
import java.util.Set;
+/**
+ * Does not contains snapshots of {@link Library} as effectiveKey can be the same than a project.
+ */
public class SnapshotCache implements BatchComponent {
// snapshots by component key
private final Map<String, Snapshot> snapshots = Maps.newHashMap();