From 1f113a9e69c5717afd18954bc236e3139794731d Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Thu, 26 Jan 2012 21:00:32 +0400 Subject: [PATCH] SONAR-3181 Fix NPE --- .../java/org/sonar/plugins/cpd/index/DbDuplicationsIndex.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 units = dao.selectCandidates(resourceSnapshotId, lastSnapshotId, languageKey); cache.clear(); // TODO Godin: maybe remove conversion of units to blocks? -- 2.39.5