ServerImpl misplaced null check

Roger Riggs Roger.Riggs at Oracle.com
Wed Jan 20 19:08:25 UTC 2016


Looks like a bug to me.
Network issues are better raised on net-dev at openjdk.java.net

Created:
8147862 Null check too late in sun.net.httpserver.ServerImpl 
<https://bugs.openjdk.java.net/browse/JDK-8147862>

Thanks, Roger

On 1/20/2016 1:18 PM, Scott Palmer wrote:
> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/net-dev/attachments/20160120/7f431b31/attachment.html>


More information about the net-dev mailing list