aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Lynggaard Hansen2012-07-05 15:15:43 (EDT)
committerHenrik Lynggaard Hansen2012-07-05 15:15:43 (EDT)
commitb4fc1bf33e1f53bc280850b0230efd46f6c03d6e (patch)
tree245738d6ebcac1748d3e2567f7f092cdc2988f6d
parentb3f23e82c67f65adc91ce3f463f3ceb272694b80 (diff)
downloadorg.eclipse.hudson.core-b4fc1bf33e1f53bc280850b0230efd46f6c03d6e.zip
org.eclipse.hudson.core-b4fc1bf33e1f53bc280850b0230efd46f6c03d6e.tar.gz
org.eclipse.hudson.core-b4fc1bf33e1f53bc280850b0230efd46f6c03d6e.tar.bz2
Guard against NPE in AbstractBuildrefs/changes/45/6645/1
if computer (c) is null a NPE will occur in the error handling of offline slaves. This change guards against this be not tryin to get the log of a null slave Change-Id: I6c122030fc03ff94588a22788ffa632b0086398d Signed-off-by: Henrik Lynggaard Hansen <henrik@hlyh.dk>
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractBuild.java26
1 files changed, 15 insertions, 11 deletions
diff --git a/hudson-core/src/main/java/hudson/model/AbstractBuild.java b/hudson-core/src/main/java/hudson/model/AbstractBuild.java
index 437187d..20121bf 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractBuild.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractBuild.java
@@ -422,19 +422,23 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
Result result = doRun(listener);
Computer c = node.toComputer();
- if (c==null || c.isOffline()) {
+ if (c == null || c.isOffline()) {
// As can be seen in HUDSON-5073, when a build fails because of the slave connectivity problem,
// error message doesn't point users to the slave. So let's do it here.
- listener.hyperlink("/computer/"+builtOn+"/log","Looks like the node went offline during the build. Check the slave log for the details.");
-
- // grab the end of the log file. This might not work very well if the slave already
- // starts reconnecting. Fixing this requires a ring buffer in slave logs.
- AnnotatedLargeText<Computer> log = c.getLogText();
- StringWriter w = new StringWriter();
- log.writeHtmlTo(Math.max(0,c.getLogFile().length()-10240),w);
-
- listener.getLogger().print(ExpandableDetailsNote.encodeTo("details",w.toString()));
- listener.getLogger().println();
+ listener.hyperlink("/computer/" + builtOn + "/log","Looks like the node went offline during the build. Check the slave log for the details.");
+
+ if (c != null) {
+ // grab the end of the log file. This might not work very well if the slave already
+ // starts reconnecting. Fixing this requires a ring buffer in slave logs.
+ AnnotatedLargeText<Computer> log = c.getLogText();
+ StringWriter w = new StringWriter();
+ log.writeHtmlTo(Math.max(0, c.getLogFile().length() - 10240), w);
+
+ listener.getLogger().print(ExpandableDetailsNote.encodeTo("details", w.toString()));
+ listener.getLogger().println();
+ } else {
+ listener.getLogger().println("No slave log available");
+ }
}
// kill run-away processes that are left by build