RFR: JDK-8015692 - java.net.BindException is thrown on Windows XP when HTTP server is started and stopped in the loop.
Chris Hegarty
chris.hegarty at oracle.com
Thu Feb 20 23:22:51 PST 2014
Mark,
I agree with you, there is certainly some additional co-ordination needed between the thread invoking the stop method and the dispatcher thread.
I wonder why you needed to add the selectNow() and the close() after you have joined the dispatcher thread? Since you are guaranteed that the dispatcher thread will have exited before join() returns?
-Chris.
On 17 Feb 2014, at 01:20, Mark Sheppard <mark.sheppard at oracle.com> wrote:
> 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