Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sun.net.httpserver.ServerImpl is leaving open connection

4245c080-e105-4873-b31f-e580a60ba2cdNov 28 2014 — edited Dec 1 2014

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.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 29 2014
Added on Nov 28 2014
1 comment
1,267 views