]> source.dussan.org Git - gitblit.git/commitdiff
Null-safe compare for ticket milestones without due date
authorFritz Schrogl <fs+github@schrogl.at>
Sun, 18 Feb 2018 15:21:33 +0000 (16:21 +0100)
committerFlorian Zschocke <fzs@users.noreply.github.com>
Mon, 10 Jun 2019 15:52:38 +0000 (17:52 +0200)
src/main/java/com/gitblit/wicket/pages/TicketsPage.java

index ecfed250f553feea4deb7314dcdf5a817a729017..ebf4dc52a334cacc070d63078579f033176c6919 100644 (file)
@@ -521,14 +521,26 @@ public class TicketsPage extends RepositoryPage {
                Collections.sort(openMilestones, new Comparator<TicketMilestone>() {\r
                        @Override\r
                        public int compare(TicketMilestone o1, TicketMilestone o2) {\r
-                               return o2.due.compareTo(o1.due);\r
+                               if (o1.due == null) {\r
+                                       return (o2.due == null) ? 0 : 1;\r
+                               } else if (o2.due == null) {\r
+                                       return -1;\r
+                               } else {\r
+                                       return o1.due.compareTo(o2.due);\r
+                               }\r
                        }\r
                });\r
 \r
                Collections.sort(closedMilestones, new Comparator<TicketMilestone>() {\r
                        @Override\r
                        public int compare(TicketMilestone o1, TicketMilestone o2) {\r
-                               return o2.due.compareTo(o1.due);\r
+                               if (o1.due == null) {\r
+                                       return (o2.due == null) ? 0 : 1;\r
+                               } else if (o2.due == null) {\r
+                                       return -1;\r
+                               } else {\r
+                                       return o1.due.compareTo(o2.due);\r
+                               }\r
                        }\r
                });\r
 \r