Skip to content

Commit

Permalink
[JENKINS-33038] correctly set executor in FutureImpl
Browse files Browse the repository at this point in the history
This patch fixes cancellation of the build linked to the Future
object. Before, the executor set in FutureImpl was always empty,
because WorkUnitContext.createWorkUnit() is not called from an
Executor thread anymore.
  • Loading branch information
ydubreuil committed Feb 19, 2016
1 parent 39110e9 commit 8d3eb20
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 3 additions & 0 deletions core/src/main/java/hudson/model/queue/WorkUnit.java
Expand Up @@ -71,6 +71,9 @@ public final class WorkUnit {

public void setExecutor(@CheckForNull Executor e) {
executor = e;
if (e != null) {
context.future.addExecutor(e);
}
}

/**
Expand Down
7 changes: 1 addition & 6 deletions core/src/main/java/hudson/model/queue/WorkUnitContext.java
Expand Up @@ -88,14 +88,9 @@ protected void onCriteriaMet() {
}

/**
* Called by the executor that executes a member {@link SubTask} that belongs to this task
* to create its {@link WorkUnit}.
* Called within the queue maintenance process to create a {@link WorkUnit} for the given {@link SubTask}
*/
public WorkUnit createWorkUnit(SubTask execUnit) {
Executor executor = Executor.currentExecutor();
if (executor != null) { // TODO is it legal for this to be called by a non-executor thread?
future.addExecutor(executor);
}
WorkUnit wu = new WorkUnit(this, execUnit);
workUnits.add(wu);
return wu;
Expand Down

0 comments on commit 8d3eb20

Please sign in to comment.