Skip to content

Commit

Permalink
[FIXED JENKINS-28384] NPE when Node.toComputer → null.
Browse files Browse the repository at this point in the history
(cherry picked from commit 86bac90)
  • Loading branch information
jglick authored and olivergondza committed May 14, 2015
1 parent 0d1efda commit aadc991
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/src/main/java/hudson/model/LoadStatistics.java
Expand Up @@ -51,6 +51,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;
import javax.annotation.CheckForNull;

/**
* Utilization statistics for a node or a set of nodes.
Expand Down Expand Up @@ -614,13 +615,17 @@ public Builder withQueueLength(int queueLength) {
return this;
}

public Builder with(Node node) {
if (node != null)
return with(node.toComputer());
public Builder with(@CheckForNull Node node) {
if (node != null) {
return with(node.toComputer());
}
return this;
}

public Builder with(Computer computer) {
public Builder with(@CheckForNull Computer computer) {
if (computer == null) {
return this;
}
if (computer.isOnline()) {
final List<Executor> executors = computer.getExecutors();
final boolean acceptingTasks = computer.isAcceptingTasks();
Expand Down

0 comments on commit aadc991

Please sign in to comment.