From 7eec1492b6f7a43b44d381f735e7f8aeaa2d1aef Mon Sep 17 00:00:00 2001 From: Edwin Kempin Date: Thu, 13 Sep 2012 13:20:11 +0200 Subject: [PATCH] Fix displaying of file diff if draft patch has been deleted Displaying any file diff for a patch set fails if the change has any gaps in its patch set history. Patch sets can be missing, if they have been drafts and were deleted. In this case displaying a file diff fails because an IndexOutOfBoundsException occurs when setting the style for the patch set link of the active patch set. Bug: issue 1555 Change-Id: Ib63e4082e27f184b4092baa08a84d89bb7932346 Signed-off-by: Edwin Kempin --- .../gerrit/client/patches/PatchSetSelectBox.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchSetSelectBox.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchSetSelectBox.java index 5d4207f8ba..afaf7fdbb2 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchSetSelectBox.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchSetSelectBox.java @@ -35,8 +35,8 @@ import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.Image; import com.google.gwtorm.client.KeyUtil; -import java.util.LinkedList; -import java.util.List; +import java.util.HashMap; +import java.util.Map; public class PatchSetSelectBox extends Composite { interface Binder extends UiBinder { @@ -63,7 +63,7 @@ public class PatchSetSelectBox extends Composite { PatchSet.Id idActive; Side side; PatchScreen.Type screenType; - List links; + Map links; @UiField HTMLPanel linkPanel; @@ -88,7 +88,7 @@ public class PatchSetSelectBox extends Composite { this.idSideA = idSideA; this.idSideB = idSideB; this.idActive = (side == Side.A) ? idSideA : idSideB; - this.links = new LinkedList(); + this.links = new HashMap(); linkPanel.clear(); @@ -105,7 +105,7 @@ public class PatchSetSelectBox extends Composite { baseLink = createLink(PatchUtil.C.patchBase(), null); } - links.add(baseLink); + links.put(0, baseLink); if (screenType == PatchScreen.Type.UNIFIED || side == Side.A) { linkPanel.add(baseLink); } @@ -117,7 +117,7 @@ public class PatchSetSelectBox extends Composite { for (Patch patch : script.getHistory()) { PatchSet.Id psId = patch.getKey().getParentKey(); Anchor anchor = createLink(Integer.toString(psId.get()), psId); - links.add(anchor); + links.put(psId.get(), anchor); linkPanel.add(anchor); }