提交 2d7afedd 编写于 作者: K Kohsuke Kawaguchi

I'm seeing an occasional SocketTimeoutException in waiting for a response from...

I'm seeing an occasional SocketTimeoutException in waiting for a response from the server. I suspect there's some concurrency issue in the ThreadPool implementation, as the problem disappears when I attach a debugger (and let it run for 8 hours.) Swapping to JDK ExecutorService to see if that makes a difference
上级 55debe8a
......@@ -128,7 +128,11 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.jar.Manifest;
import java.util.logging.Filter;
import java.util.logging.Level;
......@@ -421,6 +425,7 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
context.setMimeTypes(MIME_TYPES);
SocketConnector connector = new SocketConnector();
server.setThreadPool(new ThreadPoolImpl(new ThreadPoolExecutor(1, 10, 10L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>())));
server.addConnector(connector);
server.addUserRealm(configureUserRealm());
server.start();
......
package org.jvnet.hudson.test;
import org.mortbay.component.AbstractLifeCycle;
import org.mortbay.thread.ThreadPool;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
/**
* @author Kohsuke Kawaguchi
*/
public class ThreadPoolImpl extends AbstractLifeCycle implements ThreadPool {
private final ExecutorService es;
public ThreadPoolImpl(ExecutorService es) {
this.es = es;
}
public boolean dispatch(Runnable job) {
if (!isRunning() || job==null)
return false;
es.submit(job);
return true;
}
public void join() throws InterruptedException {
while(!es.awaitTermination(999, TimeUnit.DAYS))
;
}
public int getThreads() {
return 999;
}
public int getIdleThreads() {
return 999;
}
public boolean isLowOnThreads() {
return false;
}
@Override
protected void doStart() throws Exception {
// noop
}
@Override
protected void doStop() throws Exception {
es.shutdown();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册