提交 dab996e2 编写于 作者: K kohsuke

improve the error diagnostics when Maven terminates abruptly.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@21109 71c3de6d-444a-0410-be80-ed276b4c234a
上级 8d02146f
......@@ -26,11 +26,9 @@ package hudson.maven;
import hudson.Util;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Build;
import hudson.model.BuildListener;
import hudson.model.DependencyGraph;
import hudson.model.Hudson;
import hudson.model.Project;
import hudson.model.Result;
import hudson.model.Run;
import hudson.model.Cause.UpstreamCause;
......@@ -62,10 +60,6 @@ public abstract class AbstractMavenBuild<P extends AbstractMavenProject<P,B>,B e
/**
* Schedules all the downstream builds.
*
* @param downstreams
* List of downstream jobs that are already scheduled.
* The method will add jobs that it triggered here,
* and won't try to trigger jobs that are already in this list.
* @param listener
* Where the progress reports go.
*/
......@@ -178,6 +172,4 @@ public abstract class AbstractMavenBuild<P extends AbstractMavenProject<P,B>,B e
}
return false;
}
}
......@@ -516,7 +516,7 @@ public class MavenBuild extends AbstractMavenBuild<MavenModule,MavenBuild> {
boolean normalExit = false;
try {
Result r = process.channel.call(new Builder(
Result r = process.call(new Builder(
listener,new ProxyImpl(),
reporters.toArray(new MavenReporter[reporters.size()]), margs.toList(), systemProps));
normalExit = true;
......
......@@ -46,7 +46,6 @@ import hudson.model.TaskListener;
import hudson.model.Cause.UpstreamCause;
import hudson.remoting.Channel;
import hudson.remoting.VirtualChannel;
import hudson.remoting.RequestAbortedException;
import hudson.tasks.BuildWrapper;
import hudson.tasks.Maven.MavenInstallation;
import hudson.util.ArgumentListBuilder;
......@@ -474,18 +473,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
try {
mpa = new MavenProbeAction(project,process.channel);
addAction(mpa);
return process.channel.call(builder);
} catch (RequestAbortedException e) {
// this is normally triggered by the unexpected Maven JVM termination.
// check if the process is still alive, after giving it a bit of time to die
Thread.sleep(1000);
if(process.proc.isAlive())
throw e; // it's still alive. treat this as a bug in the code
else {
String msg = "Maven JVM terminated unexpectedly with exit code " + process.proc.join();
LOGGER.log(Level.FINE,msg,e);
throw new AbortException(msg);
}
return process.call(builder);
} finally {
builder.end(launcher);
getActions().remove(mpa);
......
......@@ -31,6 +31,7 @@ import hudson.model.TaskListener;
import hudson.remoting.Callable;
import hudson.remoting.Channel;
import hudson.remoting.VirtualChannel;
import hudson.remoting.RequestAbortedException;
import hudson.tasks.Maven.MavenInstallation;
import hudson.util.DelegatingOutputStream;
import hudson.util.NullStream;
......@@ -142,6 +143,26 @@ public final class ProcessCache {
LOGGER.log(Level.WARNING,"Failed to discard the maven process orderly",e);
}
}
/**
* Calls a {@link Callable} on the channel, with additional error diagnostics.
*/
public <V,T extends Throwable> V call(Callable<V,T> callable) throws T, IOException, InterruptedException {
try {
return channel.call(callable);
} catch (RequestAbortedException e) {
// this is normally triggered by the unexpected Maven JVM termination.
// check if the process is still alive, after giving it a bit of time to die
Thread.sleep(1000);
if(proc.isAlive())
throw e; // it's still alive. treat this as a bug in the code
else {
String msg = "Maven JVM terminated unexpectedly with exit code " + proc.join();
LOGGER.log(Level.FINE,msg,e);
throw new hudson.AbortException(msg);
}
}
}
}
static class PerChannel {
......@@ -186,7 +207,7 @@ public final class ProcessCache {
// reset the system property.
// this also serves as the sanity check.
try {
p.channel.call(new SetSystemProperties(p.systemProperties));
p.call(new SetSystemProperties(p.systemProperties));
} catch (IOException e) {
p.discard();
itr.remove();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册