improving the error handling

This commit is contained in:
Kohsuke Kawaguchi committed 2011-03-11 14:17:38 -08:00
1 parent abcb3fd8b5
commit df32805382
1 file changed
+7 -4
+7 -4
View File
@@ -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"));
}
}
});