Skip to content

Commit

Permalink
[FIXED JENKINS-14330] NPE.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Jul 5, 2012
1 parent 129e76b commit 0d5a132
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/hudson/model/Computer.java
Expand Up @@ -88,6 +88,7 @@
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.Inet4Address;
import javax.annotation.CheckForNull;

import static javax.servlet.http.HttpServletResponse.*;

Expand Down Expand Up @@ -425,7 +426,7 @@ public String getName() {
* null if the configuration has changed and the node is removed, yet the corresponding {@link Computer}
* is not yet gone.
*/
public Node getNode() {
public @CheckForNull Node getNode() {
if(nodeName==null)
return Jenkins.getInstance();
return Jenkins.getInstance().getNode(nodeName);
Expand Down
11 changes: 8 additions & 3 deletions core/src/main/java/jenkins/model/UnlabeldLoadStatistics.java
Expand Up @@ -48,18 +48,23 @@ public class UnlabeldLoadStatistics extends LoadStatistics {
@Override
public int computeIdleExecutors() {
int r=0;
for (Computer c : Jenkins.getInstance().getComputers())
if(c.getNode().getMode()== Mode.NORMAL && (c.isOnline() || c.isConnecting()))
for (Computer c : Jenkins.getInstance().getComputers()) {
Node node = c.getNode();
if (node != null && node.getMode() == Mode.NORMAL && (c.isOnline() || c.isConnecting())) {
r += c.countIdle();
}
}
return r;
}

@Override
public int computeTotalExecutors() {
int r=0;
for (Computer c : Jenkins.getInstance().getComputers()) {
if(c.getNode().getMode()==Mode.NORMAL && c.isOnline())
Node node = c.getNode();
if (node != null && node.getMode() == Mode.NORMAL && c.isOnline()) {
r += c.countExecutors();
}
}
return r;
}
Expand Down

0 comments on commit 0d5a132

Please sign in to comment.