]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1847: Meaningful exception should be thrown when saving violation with a rule...
authorGodin <mandrikov@gmail.com>
Sun, 17 Oct 2010 01:46:18 +0000 (01:46 +0000)
committerGodin <mandrikov@gmail.com>
Sun, 17 Oct 2010 01:46:18 +0000 (01:46 +0000)
sonar-batch/src/main/java/org/sonar/batch/ViolationsDao.java

index 304105442f15b57ab855af6f024cae14b63b27a3..00bc5e1cd7aacf9f457605dfe70fac721d7ffdef 100644 (file)
@@ -63,7 +63,7 @@ public class ViolationsDao {
   }
 
   public void saveViolation(Snapshot snapshot, Violation violation) {
-    if (profile == null || snapshot == null || violation == null) {
+    if (profile == null || snapshot == null || violation == null || violation.getRule() == null) {
       throw new IllegalArgumentException("Missing data to save violation : profile=" + profile + ",snapshot=" + snapshot + ",violation=" + violation);
     }
 
@@ -74,7 +74,7 @@ public class ViolationsDao {
       } else {
         LoggerFactory.getLogger(getClass()).debug("Violation is not saved because rule is not activated : violation={}", violation);
       }
-    } 
+    }
     if (activeRule != null) {
       RuleFailureModel model = toModel(snapshot, violation, activeRule);
       session.save(model);