RFR 7116200: (cs) test/java/nio/charset/coders/StreamTimeout.java fails with "Address already in use"
forax at univ-mlv.fr
Wed Apr 11 12:11:39 PDT 2012
On 04/11/2012 08:06 PM, Jim Gish wrote:
> Please review the following
> The current code uses the fixed port of 22222 and the test fails if
> that port is in use. The patch creates the socket on any open port
> using new ServerSocket(0) and then determines the port in use with
> getLocalPort() on the socket. That port is then used when creating
> the client. This ensures the test won't fail with "address already in
> Also, all sockets are closed when done. (Would appreciate comments on
> whether I have engaged in overkill here, or not.)
> Tests run: jdk_nio3 -- all pass.
> Jim Gish
there is no guarantee from the memory model that the main thread will
see the field 'so' initialized
even if the thread client has executed the method run().
And there is a kind of a race between the main thread and the thread
the main thread calls closeSocket() while the method run() may have not
It's not a clear race because the socket IOs are used as a kind of
it's really hairy.
More information about the core-libs-dev