]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaw
authorSimon Brandhof <simon.brandhof@gmail.com>
Sun, 9 Jun 2013 20:44:08 +0000 (22:44 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Sun, 9 Jun 2013 20:44:08 +0000 (22:44 +0200)
sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java
sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java

index 3d2013e6a410a7191e85d48dce397c8d2a135ba5..28fbe6b268c7b00a5ac6f63ea9d7b746c4628ec6 100644 (file)
@@ -87,7 +87,8 @@ public class IssueNotifications implements BatchComponent, ServerComponent {
 
   @CheckForNull
   private Notification createChangeNotification(DefaultIssue issue, IssueChangeContext context, Rule rule, Component project, @Nullable Component component, @Nullable String comment) {
-    if (comment == null && (issue.currentChange() == null || issue.currentChange().diffs().isEmpty())) {
+    FieldDiffs currentChange = issue.currentChange();
+    if (comment == null && (currentChange == null || currentChange.diffs().isEmpty())) {
       return null;
     }
     Notification notification = newNotification(project, "issue-changes");
@@ -105,9 +106,8 @@ public class IssueNotifications implements BatchComponent, ServerComponent {
       notification.setFieldValue("comment", comment);
     }
 
-    FieldDiffs diffs = issue.currentChange();
-    if (diffs != null) {
-      for (Map.Entry<String, FieldDiffs.Diff> entry : diffs.diffs().entrySet()) {
+    if (currentChange != null) {
+      for (Map.Entry<String, FieldDiffs.Diff> entry : currentChange.diffs().entrySet()) {
         String type = entry.getKey();
         FieldDiffs.Diff diff = entry.getValue();
         notification.setFieldValue("old." + type, diff.oldValue() != null ? diff.oldValue().toString() : null);
index abdebc9293c3a564b576d69e869fb95ec14aa60d..419b2f5b4008769e6eda9021cc6cbe9e71f2e027 100644 (file)
@@ -306,7 +306,7 @@ public class InternalRubyIssueService implements ServerComponent {
       try {
         deadLine = RubyUtils.toDate(deadLineParam);
         Date today = new Date();
-        if (deadLine.before(today) && !org.apache.commons.lang.time.DateUtils.isSameDay(deadLine, today)) {
+        if (deadLine != null && deadLine.before(today) && !org.apache.commons.lang.time.DateUtils.isSameDay(deadLine, today)) {
           result.addError(Result.Message.ofL10n("action_plans.date_cant_be_in_past"));
         }
       } catch (SonarException e) {