Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #9 from ikedam/feature/JENKINS-28824_NpeForBuilding
[JENKINS-28824] Fix NPE on the build page when a build is running.
  • Loading branch information
ikedam committed Jul 11, 2015
2 parents 47e89fc + 8dcdb67 commit 3a20793
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Expand Up @@ -80,6 +80,9 @@ private void drawMainLinksJS(String nameIt) {
}

private int encodeRunResult(MatrixRun run) {
if (run.getResult() == null) {
return 0
};
if (Result.SUCCESS.isWorseOrEqualTo(run.getResult())) {
return 0
};
Expand Down
Expand Up @@ -31,12 +31,14 @@
import hudson.matrix.MatrixProject;
import hudson.matrix.TextAxis;
import hudson.model.ParametersDefinitionProperty;
import hudson.model.queue.QueueTaskFuture;
import hudson.model.Result;

import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.JenkinsRule.WebClient;
import org.jvnet.hudson.test.SleepBuilder;

import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
Expand Down Expand Up @@ -418,4 +420,26 @@ public void testInvalidAxis() throws Exception {
assertNotNull(b.getExactRun(new Combination(axes, "value2")));
assertNull(b.getExactRun(new Combination(axes, "value3")));
}

@Bug(28824)
@Test
public void testBuildPageForBuilding() throws Exception {
MatrixProject p = j.createMatrixProject();

AxisList axes = new AxisList(new TextAxis("axis1", "value1", "value2"));
p.setAxes(axes);

p.addProperty(new ParametersDefinitionProperty(
new MatrixCombinationsParameterDefinition("combinations", "", "")
));

p.getBuildersList().add(new SleepBuilder(5000));

QueueTaskFuture<MatrixBuild> f = p.scheduleBuild2(0);

WebClient wc = j.createAllow405WebClient();
wc.getPage(p, "build");

f.cancel(true);
}
}

0 comments on commit 3a20793

Please sign in to comment.