From: Simon Brandhof Date: Sun, 9 Jun 2013 20:44:08 +0000 (+0200) Subject: Fix quality flaw X-Git-Tag: 3.6~41 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=72fbbf025107c5bad6739313c29e05e72bb528a5;p=sonarqube.git Fix quality flaw --- 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) {