From: Godin Date: Mon, 6 Dec 2010 11:25:14 +0000 (+0000) Subject: SONAR-1450: Don't do anything in ViolationPersisterDecorator if no violations for... X-Git-Tag: 2.6~405 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=73c870d39a1d5a9af9fa7c4b75e3920d555a6400;p=sonarqube.git SONAR-1450: Don't do anything in ViolationPersisterDecorator if no violations for current resource --- 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 1508abf0de8..5290bd6b02f 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 @@ -52,6 +52,9 @@ public class ViolationPersisterDecorator implements Decorator { } public void decorate(Resource resource, DecoratorContext context) { + if (context.getViolations().isEmpty()) { + return; + } // Load past violations List pastViolations = pastViolationsLoader.getPastViolations(resource); // Load current source and calculate checksums @@ -136,7 +139,7 @@ public class ViolationPersisterDecorator implements Decorator { */ private RuleFailureModel selectPastViolationUsingLine(Violation violation, Collection pastViolations) { for (RuleFailureModel pastViolation : pastViolations) { - if (ObjectUtils.equals(violation.getLineId(), pastViolation.getLine()) && StringUtils.equals(violation.getMessage(), pastViolation.getMessage())) { + if (ObjectUtils.equals(violation.getLineId(), pastViolation.getLine()) && StringUtils.equals(violation.getMessage(), pastViolation.getMessage())) { return pastViolation; } }