From 73c870d39a1d5a9af9fa7c4b75e3920d555a6400 Mon Sep 17 00:00:00 2001 From: Godin Date: Mon, 6 Dec 2010 11:25:14 +0000 Subject: [PATCH] SONAR-1450: Don't do anything in ViolationPersisterDecorator if no violations for current resource --- .../core/timemachine/ViolationPersisterDecorator.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; } } -- 2.39.5