8202252: (aio) Closed AsynchronousSocketChannel keeps completion handler alive
Alan Bateman
Alan.Bateman at oracle.com
Wed Jun 27 15:25:21 UTC 2018
On 26/06/2018 19:59, Brian Burkhalter wrote:
> https://bugs.openjdk.java.net/browse/JDK-8202252
> http://cr.openjdk.java.net/~bpb/8202252/webrev.00/
>
> Set instance variables {connect,read,write}Handler to null to allow the respective objects to be GCed.
>
> Without applying the source portion of the patch, the test fails on Linux, macOS, and Solaris.
>
The updates to finishRead and finishWrite look okay. The change to set
connectHandler to null needs more checking, I can't immediately say if
this if right. Is this part of a series of patches? I assumed the
Windows code would be changed, also the AsynchronousServerSocketChannel
implementations.
The test does this:
System.gc();
assertNull(ref.get());
The more usual check is something like this:
while (ref.get() != null) { Thread.sleep(20); }
so that the test waits until the reference is cleared.
Is there a reason why the thread uses a custom channel group? I assume
it can use the default channel group, would reduce the code a bit if you
want.
-Alan
More information about the nio-dev
mailing list