Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-9003] NPE when polling after node removed
  • Loading branch information
kutzi committed May 22, 2011
1 parent 68f5a0d commit 0b01182
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -69,6 +69,9 @@
<li class=bug>
Catch FileNotFoundException in Maven builds if Mojos are executed from a classes directory.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-5044">issue 5044</a>)
<li class=bug>
Fix NPE if node of last build isn't available anymore while polling for SCM changes.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-9003">issue 9003 </a>)
<li class=rfe>
Set NODE_NAME for master node to "master"
(<a href="http://issues.jenkins-ci.org/browse/JENKINS-9671">issue 9671</a>)
Expand Down
20 changes: 19 additions & 1 deletion core/src/main/java/hudson/model/AbstractProject.java
Expand Up @@ -1263,7 +1263,7 @@ public PollingResult poll( TaskListener listener ) {
// lock the workspace of the last build
FilePath ws=lb.getWorkspace();

if (ws==null || !ws.exists()) {
if (workspaceOffline(lb)) {
// workspace offline. build now, or nothing will ever be built
Label label = getAssignedLabel();
if (label != null && label.isSelfLabel()) {
Expand Down Expand Up @@ -1326,6 +1326,24 @@ public PollingResult poll( TaskListener listener ) {
return NO_CHANGES;
}
}

private boolean workspaceOffline(R build) throws IOException, InterruptedException {
FilePath ws = build.getWorkspace();
if (ws==null || !ws.exists()) {
return true;
}

Node builtOn = build.getBuiltOn();
if (builtOn == null) { // node built-on doesn't exist anymore
return true;
}

if (builtOn.toComputer() == null) { // node still exists, but has 0 executors - o.s.l.t.
return true;
}

return false;
}

/**
* Returns true if this user has made a commit to this project.
Expand Down

0 comments on commit 0b01182

Please sign in to comment.