提交 7156e447 编写于 作者: J Jesse Glick

Merge branch 'JENKINS-24110' of github.com:synopsys-arc-oss/jenkins

......@@ -1183,7 +1183,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
return r;
}
public R createExecutable() throws IOException {
public @CheckForNull R createExecutable() throws IOException {
if(isDisabled()) return null;
return newBuild();
}
......
......@@ -220,6 +220,13 @@ public class Executor extends Thread implements ModelObject {
try {
workUnit.context.synchronizeStart();
// this code handles the behavior of null Executables returned
// by tasks. In such case Jenkins starts the workUnit in order
// to report results to console outputs.
if (executable == null) {
throw new Error("The null Executable has been created for "+workUnit+". The task cannot be executed");
}
if (executable instanceof Actionable) {
for (Action action: workUnit.context.actions) {
((Actionable) executable).addAction(action);
......
......@@ -1892,7 +1892,7 @@ public class Queue extends ResourceController implements Saveable {
* the primary executable (such as {@link AbstractBuild}) that created out of it.
*/
@Exported
public Executable getExecutable() {
public @CheckForNull Executable getExecutable() {
return outcome!=null ? outcome.getPrimaryWorkUnit().getExecutable() : null;
}
......
......@@ -30,6 +30,7 @@ import java.util.Collection;
import java.util.AbstractCollection;
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArraySet;
import javax.annotation.Nonnull;
/**
* Controls mutual exclusion of {@link ResourceList}.
......@@ -73,7 +74,7 @@ public class ResourceController {
* @throws InterruptedException
* the thread can be interrupted while waiting for the available resources.
*/
public void execute( Runnable task, ResourceActivity activity ) throws InterruptedException {
public void execute(@Nonnull Runnable task, ResourceActivity activity ) throws InterruptedException {
ResourceList resources = activity.getResourceList();
synchronized(this) {
while(inUse.isCollidingWith(resources))
......
......@@ -33,6 +33,7 @@ import hudson.model.ResourceList;
import java.io.IOException;
import java.util.Collection;
import javax.annotation.CheckForNull;
/**
* Base class for defining filter {@link hudson.model.Queue.Task}.
......@@ -79,7 +80,7 @@ public abstract class QueueTaskFilter implements Queue.Task {
return base.getEstimatedDuration();
}
public Executable createExecutable() throws IOException {
public @CheckForNull Executable createExecutable() throws IOException {
return base.createExecutable();
}
......
......@@ -23,6 +23,7 @@
*/
package hudson.model.queue;
import hudson.model.AbstractProject;
import hudson.model.Executor;
import hudson.model.Label;
import hudson.model.Node;
......@@ -32,6 +33,7 @@ import hudson.model.ResourceActivity;
import javax.annotation.Nonnull;
import java.io.IOException;
import javax.annotation.CheckForNull;
/**
* A component of {@link Task} that represents a computation carried out by a single {@link Executor}.
......@@ -70,8 +72,11 @@ public interface SubTask extends ResourceActivity {
/**
* Creates {@link Executable}, which performs the actual execution of the task.
* @return {@link Executable} to be launched or null if the executable cannot be
* created (e.g. {@link AbstractProject} is disabled)
* @exception IOException {@link Executable} cannot be created
*/
Executable createExecutable() throws IOException;
@CheckForNull Executable createExecutable() throws IOException;
/**
* Gets the {@link Task} that this subtask belongs to.
......
......@@ -27,6 +27,7 @@ import hudson.model.Executor;
import hudson.model.Queue;
import hudson.model.Queue.Executable;
import hudson.model.Queue.Task;
import javax.annotation.CheckForNull;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.export.ExportedBean;
......@@ -63,11 +64,11 @@ public final class WorkUnit {
* {@link Executor#getCurrentWorkUnit()} and {@link WorkUnit#getExecutor()}
* form a bi-directional reachability between them.
*/
public Executor getExecutor() {
public @CheckForNull Executor getExecutor() {
return executor;
}
public void setExecutor(Executor e) {
public void setExecutor(@CheckForNull Executor e) {
executor = e;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册