Details
Description
public class UnstoppableJettyTest
{
public void testMe() throws Exception
{
Server server = new Server();
SocketConnector connector = new SocketConnector();
connector.setPort(15003);
connector.setThreadPool(new BoundedThreadPool());
server.setConnectors(new Connector[]
);
server.start();
Thread.sleep(5000);
server.stop();
}
}
This simple program eventually stops in 500 seconds. The problem with SocketConnector is that it tries to stop BoundedThreadPool before closing the server socket. But since the acceptor thread was created by the pool too, there is not way to do it: accept() in ServerSocket ignores thread interruptions.
Simply closing the socket, or calling close() before calling super.doStop() in SocketConnector.doStop() resolves this particular issue. I am not sure how it fits into the general scheme of things...