From 0cacfe01764ac3e13a74e52343ec0e4b489e5135 Mon Sep 17 00:00:00 2001 From: Konstantin Kolosovsky Date: Thu, 25 Feb 2016 17:51:41 +0300 Subject: [PATCH] IDEA-149737 Fixed NPE when rendering committed change list with null commit date --- .../util/src/com/intellij/util/text/DateFormatUtil.java | 2 +- .../changes/committed/CommittedChangeListRenderer.java | 9 ++++++--- .../src/org/jetbrains/idea/svn/history/LogEntry.java | 3 ++- .../org/jetbrains/idea/svn/history/SvnChangeList.java | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/platform/util/src/com/intellij/util/text/DateFormatUtil.java b/platform/util/src/com/intellij/util/text/DateFormatUtil.java index c404a9b840f9..0abbf6bc4679 100644 --- a/platform/util/src/com/intellij/util/text/DateFormatUtil.java +++ b/platform/util/src/com/intellij/util/text/DateFormatUtil.java @@ -159,7 +159,7 @@ public class DateFormatUtil { } @NotNull - public static String formatPrettyDateTime(Date date) { + public static String formatPrettyDateTime(@NotNull Date date) { return formatPrettyDateTime(date.getTime()); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangeListRenderer.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangeListRenderer.java index 42f1a41bc171..8204fea57c60 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangeListRenderer.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangeListRenderer.java @@ -52,7 +52,7 @@ public class CommittedChangeListRenderer extends ColoredTreeCellRenderer { myFontSize = -1; } - public static String getDateOfChangeList(final Date date) { + public static String getDateOfChangeList(@NotNull Date date) { return DateFormatUtil.formatPrettyDateTime(date); } @@ -90,7 +90,6 @@ public class CommittedChangeListRenderer extends ColoredTreeCellRenderer { final Container parent = tree.getParent(); final int rowX = getRowX(myTree, 2); int availableWidth = parent == null ? 100 : parent.getWidth() - rowX; - String date = ", " + getDateOfChangeList(changeList.getCommitDate()); final FontMetrics fontMetrics = tree.getFontMetrics(tree.getFont()); final FontMetrics boldMetrics = tree.getFontMetrics(tree.getFont().deriveFont(Font.BOLD)); final FontMetrics italicMetrics = tree.getFontMetrics(tree.getFont().deriveFont(Font.ITALIC)); @@ -174,7 +173,11 @@ public class CommittedChangeListRenderer extends ColoredTreeCellRenderer { } append(changeList.getCommitterName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); - append(date, SimpleTextAttributes.REGULAR_ATTRIBUTES); + if (changeList.getCommitDate() != null) { + String date = ", " + getDateOfChangeList(changeList.getCommitDate()); + + append(date, SimpleTextAttributes.REGULAR_ATTRIBUTES); + } } private static String trimLastWord(final String description) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntry.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntry.java index 1b3d12656d2b..3ff29f4eb2e4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntry.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntry.java @@ -34,7 +34,7 @@ public class LogEntry { public static final LogEntry EMPTY = new LogEntry.Builder().setRevision(-1).setHasChildren(false).build(); private final long myRevision; - private final Date myDate; + @Nullable private final Date myDate; private final String myMessage; private final String myAuthor; @NotNull private final Map myChangedPaths; @@ -89,6 +89,7 @@ public class LogEntry { return myAuthor; } + @Nullable public Date getDate() { return myDate; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnChangeList.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnChangeList.java index ce00339e2727..f3ec7b91da05 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnChangeList.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnChangeList.java @@ -170,6 +170,7 @@ public class SvnChangeList implements CommittedChangeList, VcsRevisionNumberAwar return myAuthor; } + @Nullable public Date getCommitDate() { return myDate; }