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(); SocketChannel chan = schan.accept();
// optimist there's a channel
if (chan != null) {
// Set TCP_NODELAY, if appropriate // Set TCP_NODELAY, if appropriate
if (ServerConfig.noDelay()) { if (ServerConfig.noDelay()) {
chan.socket().setTcpNoDelay(true); chan.socket().setTcpNoDelay(true);
} }
if (chan == null) {
continue; /* cancel something ? */
}
chan.configureBlocking (false); chan.configureBlocking (false);
SelectionKey newkey = chan.register (selector, SelectionKey.OP_READ); SelectionKey newkey =
chan.register (selector, SelectionKey.OP_READ);
HttpConnection c = new HttpConnection (); HttpConnection c = new HttpConnection ();
c.selectionKey = newkey; c.selectionKey = newkey;
c.setChannel (chan); c.setChannel (chan);
newkey.attach (c); newkey.attach (c);
requestStarted (c); requestStarted (c);
allConnections.add (c); allConnections.add (c);
}
} else { } else {
try { try {
if (key.isReadable()) { if (key.isReadable()) {