From 0b0b868805e43d5b7bcafbdf22a59960a3baeeb0 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 5 Nov 2014 17:19:45 -0500 Subject: [PATCH] [JENKINS-2786] Makes no sense for Computer.currentComputer to return MasterComputer when not on an executor thread. --- core/src/main/java/hudson/model/Computer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/model/Computer.java b/core/src/main/java/hudson/model/Computer.java index ba10094914..f27ba71e1d 100644 --- a/core/src/main/java/hudson/model/Computer.java +++ b/core/src/main/java/hudson/model/Computer.java @@ -1313,11 +1313,11 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces * Gets the current {@link Computer} that the build is running. * This method only works when called during a build, such as by * {@link hudson.tasks.Publisher}, {@link hudson.tasks.BuildWrapper}, etc. + * @return the {@link Computer} associated with {@link Executor#currentExecutor}, or null if not on an executor thread */ - public static Computer currentComputer() { + public static @Nullable Computer currentComputer() { Executor e = Executor.currentExecutor(); - // If no executor then must be on master node - return e != null ? e.getOwner() : Jenkins.getInstance().toComputer(); + return e != null ? e.getOwner() : null; } /**