From: Fritz Schrogl Date: Sun, 18 Feb 2018 15:21:33 +0000 (+0100) Subject: Null-safe compare for ticket milestones without due date X-Git-Tag: r1.9.0~45 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a92a8fb1a1ea61783a6a9563aa9f6c0967c76089;p=gitblit.git Null-safe compare for ticket milestones without due date --- diff --git a/src/main/java/com/gitblit/wicket/pages/TicketsPage.java b/src/main/java/com/gitblit/wicket/pages/TicketsPage.java index ecfed250..ebf4dc52 100644 --- a/src/main/java/com/gitblit/wicket/pages/TicketsPage.java +++ b/src/main/java/com/gitblit/wicket/pages/TicketsPage.java @@ -521,14 +521,26 @@ public class TicketsPage extends RepositoryPage { Collections.sort(openMilestones, new Comparator() { @Override public int compare(TicketMilestone o1, TicketMilestone o2) { - return o2.due.compareTo(o1.due); + if (o1.due == null) { + return (o2.due == null) ? 0 : 1; + } else if (o2.due == null) { + return -1; + } else { + return o1.due.compareTo(o2.due); + } } }); Collections.sort(closedMilestones, new Comparator() { @Override public int compare(TicketMilestone o1, TicketMilestone o2) { - return o2.due.compareTo(o1.due); + if (o1.due == null) { + return (o2.due == null) ? 0 : 1; + } else if (o2.due == null) { + return -1; + } else { + return o1.due.compareTo(o2.due); + } } });