I am passing ThreadPoolExecutor object to this server implementation through com.sun.net.httpserver.HttpServer API for its task execution. When there is no more task handling capacity to this executor it throws java.util.concurrent.RejectedExecutionException exception. But this server implementation only catch IOException and HttpError exception and closes the connection. So in the case of RejectedExecutionException it has no handling and the connection remains open. Now client has no idea what is happening to the connection as it neigher responded nor closed the connection.
Below is the code base part of ServerImpl:
public void handle (SocketChannel chan, HttpConnection conn)
throws IOException {
try {
Exchange t = new Exchange (chan, protocol, conn);
executor.execute (t);
}
catch (HttpError e1) {
logger.log (Level.FINER, "Dispatcher (4)", e1);
closeConnection(conn);
}
catch (IOException e) {
logger.log (Level.FINER, "Dispatcher (5)", e);
closeConnection(conn);
}
//No handling for RejectedExecutionException
}
So please suggest what we should do as developer so that connection can be closed properly when server is not able to handle it properly.