提交 82d14407 编写于 作者: J Jesse Glick

Trying to avoid an NPE reported by a 1.537 user with the Multijob plugin (patched 1.10).

java.lang.NullPointerException
	at hudson.model.queue.FutureImpl.cancel(FutureImpl.java:78)
	at com.tikal.jenkins.plugins.multijob.MultiJobBuilder.perform(MultiJobBuilder.java:156)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:781)
	at hudson.model.Build$BuildExecution.build(Build.java:199)
	at hudson.model.Build$BuildExecution.doRun(Build.java:160)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:562)
	at com.tikal.jenkins.plugins.multijob.MultiJobBuild$MultiJobRunnerImpl.run(MultiJobBuild.java:70)
	at hudson.model.Run.execute(Run.java:1665)
	at hudson.model.Run.run(Run.java:1612)
	at com.tikal.jenkins.plugins.multijob.MultiJobBuild.run(MultiJobBuild.java:63)
	at hudson.model.ResourceController.execute(ResourceController.java:88)
	at hudson.model.Executor.run(Executor.java:230)
上级 abe00746
......@@ -58,6 +58,7 @@ import java.util.logging.Logger;
import static hudson.model.queue.Executables.*;
import static java.util.logging.Level.*;
import javax.annotation.CheckForNull;
/**
......@@ -566,7 +567,7 @@ public class Executor extends Thread implements ModelObject {
/**
* Returns the executor of the current thread or null if current thread is not an executor.
*/
public static Executor currentExecutor() {
public static @CheckForNull Executor currentExecutor() {
Thread t = Thread.currentThread();
if (t instanceof Executor) return (Executor) t;
return IMPERSONATION.get();
......
......@@ -34,6 +34,7 @@ import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import javax.annotation.Nonnull;
/**
* Created when {@link hudson.model.Queue.Item} is created so that the caller can track the progress of the task.
......@@ -83,7 +84,7 @@ public final class FutureImpl extends AsyncFutureImpl<Executable> implements Que
}
}
synchronized void addExecutor(Executor executor) {
synchronized void addExecutor(@Nonnull Executor executor) {
this.executors.add(executor);
}
}
......@@ -91,7 +91,10 @@ public final class WorkUnitContext {
* to create its {@link WorkUnit}.
*/
public WorkUnit createWorkUnit(SubTask execUnit) {
future.addExecutor(Executor.currentExecutor());
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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册