From 9b941d017228a236d733abce183b2fecef69d682 Mon Sep 17 00:00:00 2001 From: Mathias Kinzler Date: Mon, 14 Mar 2011 15:40:22 +0100 Subject: [PATCH] Avoid NullPointerException in PlotCommit Bug: 339289 Change-Id: Idf36f080ae6638c2bdbe11d69a4ad870851622b1 Signed-off-by: Mathias Kinzler --- .../src/org/eclipse/jgit/revplot/AbstractPlotRenderer.java | 2 +- .../src/org/eclipse/jgit/revplot/PlotWalk.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/AbstractPlotRenderer.java b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/AbstractPlotRenderer.java index 10d37ea07a..a641dee545 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/AbstractPlotRenderer.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/AbstractPlotRenderer.java @@ -148,7 +148,7 @@ public abstract class AbstractPlotRenderer { drawCommitDot(dotX, dotY, dotSize, dotSize); int textx = Math.max(maxCenter + LANE_WIDTH / 2, dotX + dotSize) + 8; - int n = commit.refs == null ? 0 : commit.refs.length; + int n = commit.refs.length; for (int i = 0; i < n; ++i) { textx += drawLabel(textx + dotSize, h/2, commit.refs[i]); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java index 53020f49d4..ea2437ff77 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java @@ -114,14 +114,13 @@ public class PlotWalk extends RevWalk { private Ref[] getRefs(final AnyObjectId commitId) { Collection list = reverseRefMap.get(commitId); - Ref[] tags; if (list == null) - tags = null; + return PlotCommit.NO_REFS; else { - tags = list.toArray(new Ref[list.size()]); + Ref[] tags = list.toArray(new Ref[list.size()]); Arrays.sort(tags, new PlotRefComparator()); + return tags; } - return tags; } class PlotRefComparator implements Comparator { -- 2.39.5