mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 05:52:26 +00:00
Adding more probe points to watch out for sudden thread death.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@10156 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
ee6ec599eb
commit
19a078bcf9
3 files changed
+41
-2
No files matched your search
@@ -16,6 +16,7 @@ import hudson.tasks.Publisher;
|
||||
import hudson.util.DaemonThreadFactory;
|
||||
import hudson.util.RemotingDiagnostics;
|
||||
import hudson.util.RunList;
|
||||
import hudson.util.ExceptionCatchingThreadFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
@@ -386,7 +387,7 @@ public abstract class Computer extends AbstractModelObject implements AccessCont
|
||||
return RemotingDiagnostics.getThreadDump(getChannel());
|
||||
}
|
||||
|
||||
public static final ExecutorService threadPoolForRemoting = Executors.newCachedThreadPool(new DaemonThreadFactory());
|
||||
public static final ExecutorService threadPoolForRemoting = Executors.newCachedThreadPool(new ExceptionCatchingThreadFactory(new DaemonThreadFactory()));
|
||||
|
||||
//
|
||||
//
|
||||
|
||||
@@ -135,7 +135,8 @@ public class CompressedFile {
|
||||
* this should be a fairly low-priority task.
|
||||
*/
|
||||
private static final ExecutorService compressionThread = new ThreadPoolExecutor(
|
||||
0, 1, 5L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new DaemonThreadFactory());
|
||||
0, 1, 5L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(),
|
||||
new ExceptionCatchingThreadFactory(new DaemonThreadFactory()));
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(CompressedFile.class.getName());
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package hudson.util;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* {@link ThreadFactory} that creates a thread, which in turn displays a stack trace
|
||||
* when it terminates unexpectedly.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @since 1.226
|
||||
*/
|
||||
public class ExceptionCatchingThreadFactory implements ThreadFactory, Thread.UncaughtExceptionHandler {
|
||||
private final ThreadFactory core;
|
||||
|
||||
public ExceptionCatchingThreadFactory() {
|
||||
this(Executors.defaultThreadFactory());
|
||||
}
|
||||
|
||||
public ExceptionCatchingThreadFactory(ThreadFactory core) {
|
||||
this.core = core;
|
||||
}
|
||||
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread t = core.newThread(r);
|
||||
t.setUncaughtExceptionHandler(this);
|
||||
return t;
|
||||
}
|
||||
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
LOGGER.log(Level.WARNING, "Thread "+t.getName()+" terminated unexpectedly",e);
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ExceptionCatchingThreadFactory.class.getName());
|
||||
}
|
||||
Reference in new issue
Block a user