From dab996e26ae4b853e935ec8702f65fa5ea98178f Mon Sep 17 00:00:00 2001 From: kohsuke Date: Thu, 27 Aug 2009 05:36:56 +0000 Subject: [PATCH] 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 --- .../java/hudson/maven/AbstractMavenBuild.java | 8 ------- .../main/java/hudson/maven/MavenBuild.java | 2 +- .../hudson/maven/MavenModuleSetBuild.java | 14 +---------- .../main/java/hudson/maven/ProcessCache.java | 23 ++++++++++++++++++- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/AbstractMavenBuild.java b/maven-plugin/src/main/java/hudson/maven/AbstractMavenBuild.java index cea39350f8..6e70703d65 100644 --- a/maven-plugin/src/main/java/hudson/maven/AbstractMavenBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/AbstractMavenBuild.java @@ -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

,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

,B e } return false; } - - } diff --git a/maven-plugin/src/main/java/hudson/maven/MavenBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenBuild.java index c50faf0b6a..4788033151 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenBuild.java @@ -516,7 +516,7 @@ public class MavenBuild extends AbstractMavenBuild { 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; diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index 6d3a0d596d..7feb3fb6af 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -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 V call(Callable 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();