8147862: Null check too late in sun.net.httpserver.ServerImpl

Reviewed-by: chegar
This commit is contained in:
Mark Sheppard 2016-01-24 22:27:16 +00:00
parent 0e9196c50f
commit 1cbdf12c05

View file

@ -373,22 +373,22 @@ class ServerImpl implements TimeSource {
}
SocketChannel chan = schan.accept();
// Set TCP_NODELAY, if appropriate
if (ServerConfig.noDelay()) {
chan.socket().setTcpNoDelay(true);
// optimist there's a channel
if (chan != null) {
// Set TCP_NODELAY, if appropriate
if (ServerConfig.noDelay()) {
chan.socket().setTcpNoDelay(true);
}
chan.configureBlocking (false);
SelectionKey newkey =
chan.register (selector, SelectionKey.OP_READ);
HttpConnection c = new HttpConnection ();
c.selectionKey = newkey;
c.setChannel (chan);
newkey.attach (c);
requestStarted (c);
allConnections.add (c);
}
if (chan == null) {
continue; /* cancel something ? */
}
chan.configureBlocking (false);
SelectionKey newkey = chan.register (selector, SelectionKey.OP_READ);
HttpConnection c = new HttpConnection ();
c.selectionKey = newkey;
c.setChannel (chan);
newkey.attach (c);
requestStarted (c);
allConnections.add (c);
} else {
try {
if (key.isReadable()) {