ServerImpl misplaced null check
Scott Palmer
swpalmer at gmail.com
Wed Jan 20 18:18:13 UTC 2016
I was searching for a way to set TCP_NODELAY for an Endpoint using the default HTTP server and after finally tracking down the existence of the “sun.net.httpserver.nodelay” system property I noticed what appears to be a mistake (though not a big one) in the source code.
Look here:
http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/c3ecf996006a/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java#l377
Notice the null check on ‘chan’ is performed after it may have been dereferenced to set the TCP_NODELAY on the channel’s socket. If chan truly can be null at that point, the check needs to be move up a few lines.
Regards,
Scott
More information about the build-dev
mailing list