Skip to content

Commit

Permalink
[JENKINS-2786] Makes no sense for Computer.currentComputer to return …
Browse files Browse the repository at this point in the history
…MasterComputer when not on an executor thread.
  • Loading branch information
jglick committed Nov 5, 2014
1 parent e607048 commit 0b0b868
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/src/main/java/hudson/model/Computer.java
Expand Up @@ -1313,11 +1313,11 @@ public void doProgressiveLog( StaplerRequest req, StaplerResponse rsp) throws IO
* 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;
}

/**
Expand Down

0 comments on commit 0b0b868

Please sign in to comment.