JDK 10 RFR of 8147615: (fc) FileChannelImpl has no finalizer
Roger Riggs
Roger.Riggs at Oracle.com
Tue Sep 5 21:28:52 UTC 2017
Hi Brian,
Can the function to close and invalidate the FileDescriptor be encapsulated
in FileDescriptor itself? It would be another method on
JavaIOFileDescriptorAccess
but would bring the handling of close together in one place.
Currently, there are several places that replicate the code to do that
and FileDescriptor
already has Windows and Unix versions.
It might also reasonably handle the case where the FileDescriptor has a
parent and should or should
not call the closeables.
[fyi, in parallel, I'm working on changing FIS/FOS/RandomAccess file to
use the Cleaner.]
Thanks, Roger
On 9/1/2017 10:56 AM, Brian Burkhalter wrote:
> Please review at your convenience:
>
> https://bugs.openjdk.java.net/browse/JDK-8147615
> http://cr.openjdk.java.net/~bpb/8147615/webrev.00/
>
> There is a question at line 106 of FileChannelImpl.java which needs to be resolved.
>
> Another question is whether a synchronized block should be used in or around invalidateAndClose() in addition to relying on the pseudo-synchronization of checking the FileDescriptor validity. It is necessary to invalidate the FileDescriptor in any case as otherwise “Bad file descriptor” exceptions occur. This is likely due to the cleaning action attempting to close a native file descriptor which was already closed when the channel was closed.
>
> That this actually works was verified by instrumenting FileChannelImpl$Closer#run() with a print statement which was since removed. The issue has however been labelled “noreg-hard” as there appears to be no way to verify the fix without such instrumentation or via existing public APIs.
>
> Thanks,
>
> Brian
More information about the nio-dev
mailing list