aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-core-plugin/src
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-01-10 18:46:53 +0100
committersimonbrandhof <simon.brandhof@gmail.com>2011-01-10 18:46:53 +0100
commitc8d150808ca30044b753923efa30a46ee7a9f1db (patch)
treeb4e3bfb943f9532b9f76dce29cd65af471fda4d8 /plugins/sonar-core-plugin/src
parent64438bb95377cb144b538dc134e6db33ba4e615d (diff)
downloadsonarqube-c8d150808ca30044b753923efa30a46ee7a9f1db.tar.gz
sonarqube-c8d150808ca30044b753923efa30a46ee7a9f1db.zip
merge 2.5-RC2: missing close of input stream
Diffstat (limited to 'plugins/sonar-core-plugin/src')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java
index 9d90f3e81b2..6f2df32db49 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java
@@ -88,18 +88,22 @@ public class ViolationPersisterDecorator implements Decorator {
* @return checksums, never null
*/
private List<String> getChecksums(SnapshotSource source) {
- return source == null || source.getData() == null ? Collections.<String> emptyList() : getChecksums(source.getData());
+ return source == null || source.getData() == null ? Collections.<String>emptyList() : getChecksums(source.getData());
}
static List<String> getChecksums(String data) {
List<String> result = Lists.newArrayList();
+ StringInputStream stream = new StringInputStream(data);
try {
- List<String> lines = IOUtils.readLines(new StringInputStream(data));
+ List<String> lines = IOUtils.readLines(stream);
for (String line : lines) {
result.add(getChecksum(line));
}
} catch (IOException e) {
throw new SonarException("Unable to calculate checksums", e);
+
+ } finally {
+ IOUtils.closeQuietly(stream);
}
return result;
}
@@ -123,11 +127,11 @@ public class ViolationPersisterDecorator implements Decorator {
* Search for past violation.
*/
RuleFailureModel selectPastViolation(Violation violation, Multimap<Rule, RuleFailureModel> pastViolationsByRule) {
- // skip violation, if there is no past violations with same rule
- if (!pastViolationsByRule.containsKey(violation.getRule())) {
+ Collection<RuleFailureModel> pastViolations = pastViolationsByRule.get(violation.getRule());
+ if (pastViolations==null || pastViolations.isEmpty()) {
+ // skip violation, if there is no past violations with same rule
return null;
}
- Collection<RuleFailureModel> pastViolations = pastViolationsByRule.get(violation.getRule());
RuleFailureModel found = selectPastViolationUsingLine(violation, pastViolations);
if (found == null) {
found = selectPastViolationUsingChecksum(violation, pastViolations);