From df3280538233d1993a2ded3aec8387447aa6ab6d Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 11 Mar 2011 11:32:34 -0800 Subject: [PATCH] improving the error handling --- core/src/main/java/hudson/Proc.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/hudson/Proc.java b/core/src/main/java/hudson/Proc.java index 0f3ffd2983..7a6ec01ece 100644 --- a/core/src/main/java/hudson/Proc.java +++ b/core/src/main/java/hudson/Proc.java @@ -26,6 +26,8 @@ package hudson; import hudson.Launcher.ProcStarter; import hudson.model.TaskListener; import hudson.remoting.Channel; +import hudson.util.DaemonThreadFactory; +import hudson.util.ExceptionCatchingThreadFactory; import hudson.util.IOException2; import hudson.util.NullStream; import hudson.util.StreamCopyThread; @@ -130,7 +132,8 @@ public abstract class Proc { */ public abstract OutputStream getStdin(); - private static final ExecutorService executor = Executors.newCachedThreadPool(); + private static final ExecutorService executor = Executors.newCachedThreadPool(new ExceptionCatchingThreadFactory(new DaemonThreadFactory())); + /** * Like {@link #join} but can be given a maximum time to wait. * @param timeout number of time units @@ -154,11 +157,11 @@ public abstract class Proc { kill(); } } catch (InterruptedException x) { - listener.error(x.toString()); + x.printStackTrace(listener.error("Failed to join a process")); } catch (IOException x) { - listener.error(x.toString()); + x.printStackTrace(listener.error("Failed to join a process")); } catch (RuntimeException x) { - listener.error(x.toString()); + x.printStackTrace(listener.error("Failed to join a process")); } } });