From dc57f029208f3938c774dbc319d64c3190a8cdb6 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Wed, 26 Jun 2013 17:09:52 +0900 Subject: Allow label values to be configured with no text Internal Server Error is raised during Gerrit startup if a project is configured with a label that has a value with no text: [label My-Label] value = -1 Failed value = 0 value = +1 Passed (Note that there is no text after "value = 0".) Internal Server Error is raised due to IndexOutOfBoundsException while constructing a LabelValue and assuming that the label has both a numeric value and a text value. Fix this by checking if there is a text value, and if there is no text value, defaulting to an empty string. Change-Id: Ib2f0532e64be745ba1ed83c372e804743a5afa7e --- .../src/main/java/com/google/gerrit/server/git/ProjectConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectConfig.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectConfig.java index 83560c106e..2e14dfb40c 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectConfig.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectConfig.java @@ -528,9 +528,10 @@ public class ProjectConfig extends VersionedMetaData { if (parts.isEmpty()) { throw new IllegalArgumentException("empty value"); } + String valueText = parts.size() > 1 ? parts.get(1) : ""; return new LabelValue( Shorts.checkedCast(PermissionRule.parseInt(parts.get(0))), - parts.get(1)); + valueText); } private void loadLabelSections(Config rc) throws IOException { -- cgit v1.2.3