diff options
author | Freddy Mallet <freddy.mallet@gmail.com> | 2011-04-23 21:32:25 +0200 |
---|---|---|
committer | Freddy Mallet <freddy.mallet@gmail.com> | 2011-04-23 21:32:25 +0200 |
commit | c065b623436c0c58c7f98fba9e6e7c831725c3c6 (patch) | |
tree | 477d89fd84fd39f6d64d1c02ce71c4aef7255eea /plugins/sonar-core-plugin | |
parent | 3e265a43011c4bc6c9b8c5df4484fcef8ac7965b (diff) | |
download | sonarqube-c065b623436c0c58c7f98fba9e6e7c831725c3c6.tar.gz sonarqube-c065b623436c0c58c7f98fba9e6e7c831725c3c6.zip |
SONAR-2358 Reapply patch 'Mechanism to calculate checksums for violations is unstable'
Diffstat (limited to 'plugins/sonar-core-plugin')
-rw-r--r-- | plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java | 22 |
1 files changed, 7 insertions, 15 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 202838755a3..cd122a1c635 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 @@ -19,7 +19,6 @@ */ package org.sonar.plugins.core.timemachine; -import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.IdentityHashMap; @@ -27,9 +26,7 @@ import java.util.List; import java.util.Map; import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.codehaus.plexus.util.StringInputStream; import org.sonar.api.batch.Decorator; import org.sonar.api.batch.DecoratorBarriers; import org.sonar.api.batch.DecoratorContext; @@ -40,7 +37,6 @@ import org.sonar.api.database.model.SnapshotSource; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; import org.sonar.api.rules.Violation; -import org.sonar.api.utils.SonarException; import org.sonar.batch.components.PastViolationsLoader; import org.sonar.batch.index.ViolationPersister; @@ -197,19 +193,15 @@ public class ViolationPersisterDecorator implements Decorator { return source == null || source.getData() == null ? Collections.<String> emptyList() : getChecksums(source.getData()); } + /** + * @param data + * can't be null + */ static List<String> getChecksums(String data) { + String[] lines = data.split("\r?\n|\r", -1); List<String> result = Lists.newArrayList(); - StringInputStream stream = new StringInputStream(data); - try { - 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); + for (String line : lines) { + result.add(getChecksum(line)); } return result; } |