From 72fbbf025107c5bad6739313c29e05e72bb528a5 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Sun, 9 Jun 2013 22:44:08 +0200 Subject: [PATCH] Fix quality flaw --- .../java/org/sonar/core/issue/IssueNotifications.java | 8 ++++---- .../org/sonar/server/issue/InternalRubyIssueService.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java b/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java index 3d2013e6a41..28fbe6b268c 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java @@ -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 entry : diffs.diffs().entrySet()) { + if (currentChange != null) { + for (Map.Entry entry : currentChange.diffs().entrySet()) { String type = entry.getKey(); FieldDiffs.Diff diff = entry.getValue(); notification.setFieldValue("old." + type, diff.oldValue() != null ? diff.oldValue().toString() : null); diff --git a/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java b/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java index abdebc9293c..419b2f5b400 100644 --- a/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java +++ b/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java @@ -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) { -- 2.39.5