RFR: JDK-8015692 - java.net.BindException is thrown on Windows XP when HTTP server is started and stopped in the loop.

Mark Sheppard mark.sheppard at oracle.com
Sun Feb 16 17:20:09 PST 2014


Hi

     Please oblige and review the changes in the webrev

http://cr.openjdk.java.net/~msheppar/8015692/jdk9/webrev/

to address the issue raised in the bug

https://bugs.openjdk.java.net/browse/JDK-8015692

Summary:
a series Junit tests which start stop instances of an 
com.sun.net.httpserver.HttpServer failed due to
java.net.BindException: Address already in use: bind

This was raised against Windows XP, but the sample test to reproduce the 
issue
was run on Windows 7, and the problem was seen to occur on this OS also.
The sample was run against jdk7, jdk8 and jdk9: reproducible on each.

On investigation it  appears that some additional co-ordination is 
required between the
HttpServer's  (actually SereverImpl) dispatcher thread and the thread 
invoking the stop
method. This change has amended the stop method to wait for the 
Dispatcher thread to complete, then
invokes the selector's selectNow, to handled cancelled events, and 
closes the selector.
The selector.close() has been removed from the Dispatcher's run method.

regards
Mark


More information about the net-dev mailing list