8147862: Null check too late in sun.net.httpserver.ServerImpl
Reviewed-by: chegar
--- a/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java Fri Jan 08 19:53:36 2016 -0800
+++ b/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java Sun Jan 24 22:27:16 2016 +0000
@@ -373,22 +373,22 @@
}
SocketChannel chan = schan.accept();
- // Set TCP_NODELAY, if appropriate
- if (ServerConfig.noDelay()) {
- chan.socket().setTcpNoDelay(true);
- }
-
- if (chan == null) {
- continue; /* cancel something ? */
+ // 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);
}
- 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()) {