Skip to content

Commit

Permalink
[FIXED JENKINS-19135] Permit a user to configure an axis with no valu…
Browse files Browse the repository at this point in the history
…es without throwing exceptions.

The project cannot be usefully built in this case but at least they can go back and reconfigure it.
Also fixing Layouter.Column to not throw NoSuchElementException (in violation of Iterator contract)
and thus break project overview when there is an empty Axis in the trivial list (due to an unintentional IndexOutOfBoundsException).
  • Loading branch information
jglick committed Aug 14, 2013
1 parent b52e32e commit 58c8a93
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -55,6 +55,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=bug>
Ungraceful handling of empty matrix project axes.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-19135">issue 19135</a>)
<li class=bug>
A malformed JUnit result file should mark that test suite as a failure, but not interrupt archiving of other tests.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-19186">issue 19186</a>)
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/hudson/matrix/Axis.java
Expand Up @@ -76,10 +76,11 @@ public class Axis extends AbstractDescribableImpl<Axis> implements Comparable<Ax
public final List<String> values;

public Axis(String name, List<String> values) {
if (values == null || values.isEmpty()) {
values = Collections.emptyList();
}
this.name = name;
this.values = new ArrayList<String>(values);
if(values.isEmpty())
throw new IllegalArgumentException(); // bug in the code
}

public Axis(String name, String... values) {
Expand Down
7 changes: 5 additions & 2 deletions core/src/main/java/hudson/matrix/Layouter.java
Expand Up @@ -201,8 +201,11 @@ public T get(int zp) {
buildMap(xp,x);
buildMap(yp,y);
buildMap(zp,z);
for (Axis a : trivial)
m.put(a.name,a.value(0));
for (Axis a : trivial) {
if (a.size() > 0) {
m.put(a.name, a.value(0));
}
}
return getT(new Combination(m));
}

Expand Down

0 comments on commit 58c8a93

Please sign in to comment.