aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-cpd-plugin/src
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2012-01-26 21:00:32 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2012-01-26 21:27:17 +0400
commit1f113a9e69c5717afd18954bc236e3139794731d (patch)
tree99d256a00d6bae92146c02b728962dde4d9a1027 /plugins/sonar-cpd-plugin/src
parent9ef0ec8571badea96052ffdddbcad5c09137e5fe (diff)
downloadsonarqube-1f113a9e69c5717afd18954bc236e3139794731d.tar.gz
sonarqube-1f113a9e69c5717afd18954bc236e3139794731d.zip
SONAR-3181 Fix NPE
Diffstat (limited to 'plugins/sonar-cpd-plugin/src')
-rw-r--r--plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/DbDuplicationsIndex.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/DbDuplicationsIndex.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/DbDuplicationsIndex.java
index 23928299b90..ec231780acc 100644
--- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/DbDuplicationsIndex.java
+++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/DbDuplicationsIndex.java
@@ -42,6 +42,7 @@ public class DbDuplicationsIndex {
private final ResourcePersister resourcePersister;
private final int currentProjectSnapshotId;
private final Integer lastSnapshotId;
+ private final String languageKey;
private DuplicationDao dao;
@@ -52,6 +53,7 @@ public class DbDuplicationsIndex {
Snapshot lastSnapshot = resourcePersister.getLastSnapshot(currentSnapshot, false);
this.currentProjectSnapshotId = currentSnapshot.getId();
this.lastSnapshotId = lastSnapshot == null ? null : lastSnapshot.getId();
+ this.languageKey = currentProject.getLanguageKey();
}
int getSnapshotIdFor(Resource resource) {
@@ -60,7 +62,6 @@ public class DbDuplicationsIndex {
public void prepareCache(Resource resource) {
int resourceSnapshotId = getSnapshotIdFor(resource);
- String languageKey = resource.getLanguage().getKey();
List<DuplicationUnitDto> units = dao.selectCandidates(resourceSnapshotId, lastSnapshotId, languageKey);
cache.clear();
// TODO Godin: maybe remove conversion of units to blocks?