提交 a5ac77eb 编写于 作者: K kohsuke

fixed #614 and #292. When the executor thread is interrupted, it is handled as...

fixed #614 and #292. When the executor thread is interrupted, it is handled as an abort, not as a failure.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3499 71c3de6d-444a-0410-be80-ed276b4c234a
上级 c99e53c5
......@@ -250,7 +250,11 @@ public abstract class Launcher {
public Integer call() throws IOException {
Proc p = new LocalLauncher(TaskListener.NULL).launch(cmd, env, in, out,
workDir ==null ? null : new FilePath(new File(workDir)));
return p.join();
try {
return p.join();
} catch (InterruptedException e) {
return -1;
}
}
private static final long serialVersionUID = 1L;
......
......@@ -32,7 +32,7 @@ public abstract class Proc {
* if there's an error killing a process
* and a stack trace could help the trouble-shooting.
*/
public abstract void kill() throws IOException;
public abstract void kill() throws IOException, InterruptedException;
/**
* Waits for the completion of the process.
......@@ -46,7 +46,7 @@ public abstract class Proc {
* if there's an error launching/joining a process
* and a stack trace could help the trouble-shooting.
*/
public abstract int join() throws IOException;
public abstract int join() throws IOException, InterruptedException;
/**
* Locally launched process.
......@@ -96,7 +96,7 @@ public abstract class Proc {
* Waits for the completion of the process.
*/
@Override
public int join() {
public int join() throws InterruptedException {
try {
t1.join();
t2.join();
......@@ -104,12 +104,12 @@ public abstract class Proc {
} catch (InterruptedException e) {
// aborting. kill the process
proc.destroy();
return -1;
throw e;
}
}
@Override
public void kill() {
public void kill() throws InterruptedException {
proc.destroy();
join();
}
......@@ -160,19 +160,19 @@ public abstract class Proc {
}
@Override
public void kill() throws IOException {
public void kill() throws IOException, InterruptedException {
process.cancel(true);
join();
}
@Override
public int join() throws IOException {
public int join() throws IOException, InterruptedException {
try {
return process.get();
} catch (InterruptedException e) {
// aborting. kill the process
process.cancel(true);
return -1;
throw e;
} catch (ExecutionException e) {
if(e.getCause() instanceof IOException)
throw (IOException)e.getCause();
......
......@@ -134,7 +134,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
return Result.SUCCESS;
}
private void createLastSuccessfulLink(BuildListener listener) {
private void createLastSuccessfulLink(BuildListener listener) throws InterruptedException {
if(!isWindows()) {
try {
// ignore a failure.
......
......@@ -36,6 +36,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import java.util.logging.Level;
/**
* A particular execution of {@link Job}.
......@@ -563,6 +564,11 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
throw t;
} catch( RunnerAbortedException e ) {
result = Result.FAILURE;
} catch( InterruptedException e) {
// aborted
result = Result.ABORTED;
listener.getLogger().println("Build was aborted");
LOGGER.log(Level.INFO,toString()+" aborted",e);
} catch( Throwable e ) {
handleFatalBuildProblem(listener,e);
result = Result.FAILURE;
......
......@@ -742,7 +742,7 @@ public class CVSSCM extends SCM implements Serializable {
* @param out
* Receives output from the executed program.
*/
protected final boolean run(Launcher launcher, ArgumentListBuilder cmd, TaskListener listener, FilePath dir, OutputStream out) throws IOException {
protected final boolean run(Launcher launcher, ArgumentListBuilder cmd, TaskListener listener, FilePath dir, OutputStream out) throws IOException, InterruptedException {
Map<String,String> env = createEnvVarMap(true);
int r = launcher.launch(cmd.toCommandArray(),env,out,dir).join();
......@@ -752,7 +752,7 @@ public class CVSSCM extends SCM implements Serializable {
return r==0;
}
protected final boolean run(Launcher launcher, ArgumentListBuilder cmd, TaskListener listener, FilePath dir) throws IOException {
protected final boolean run(Launcher launcher, ArgumentListBuilder cmd, TaskListener listener, FilePath dir) throws IOException, InterruptedException {
return run(launcher,cmd,listener,dir,listener.getLogger());
}
......@@ -912,7 +912,7 @@ public class CVSSCM extends SCM implements Serializable {
/**
* Displays "cvs --version" for trouble shooting.
*/
public void doVersion(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
public void doVersion(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, InterruptedException {
ByteBuffer baos = new ByteBuffer();
try {
Proc proc = Hudson.getInstance().createLauncher(TaskListener.NULL).launch(
......@@ -1037,7 +1037,7 @@ public class CVSSCM extends SCM implements Serializable {
* TODO: this apparently doesn't work. Probably related to the fact that
* cvs does some tty magic to disable echo back or whatever.
*/
public void doPostPassword(StaplerRequest req, StaplerResponse rsp) throws IOException {
public void doPostPassword(StaplerRequest req, StaplerResponse rsp) throws IOException, InterruptedException {
if(!Hudson.adminCheck(req,rsp))
return;
......
......@@ -68,7 +68,7 @@ public class Ant extends Builder {
return antOpts;
}
public boolean perform(Build build, Launcher launcher, BuildListener listener) {
public boolean perform(Build build, Launcher launcher, BuildListener listener) throws InterruptedException {
Project proj = build.getProject();
ArgumentListBuilder args = new ArgumentListBuilder();
......
......@@ -79,7 +79,7 @@ public abstract class BuildWrapper implements ExtensionPoint, Describable<BuildW
* terminates the build abnormally. Hudson will handle the exception
* and reports a nice error message.
*/
public abstract boolean tearDown( Build build, BuildListener listener ) throws IOException;
public abstract boolean tearDown( Build build, BuildListener listener ) throws IOException, InterruptedException;
}
/**
......@@ -101,5 +101,5 @@ public abstract class BuildWrapper implements ExtensionPoint, Describable<BuildW
* terminates the build abnormally. Hudson will handle the exception
* and reports a nice error message.
*/
public abstract Environment setUp( Build build, Launcher launcher, BuildListener listener ) throws IOException;
public abstract Environment setUp( Build build, Launcher launcher, BuildListener listener ) throws IOException, InterruptedException;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册