[9] RFR 8166253: (ch) FileLock object can get GC'd and result in unexpected release of file lock

Brian Burkhalter brian.burkhalter at oracle.com
Tue Jan 30 16:25:01 UTC 2018


On Jan 30, 2018, at 2:16 AM, Daniel Fuchs <daniel.fuchs at oracle.com> wrote:

> This is not a full-fledged review - just a comment:
> 
>  92     private static class FileLockReference extends WeakReference<FileLock>
>  93         implements FileLockListener {
>  94         private FileKey fileKey;
>  95
>  96         // Mirror of FileLock state for use when the lock object is no longer
>  97         // weakly reachable but the native lock has not yet been released.
>  98         private final long position;
>  99         private final long size;
> 100         private boolean isLockReleased;
> 
> Should fileKey be made final (AFAICS the field
> is never mutated) and should isLockReleased
> be volatile (appears that it could be mutated/read
> from different threads)?

I think you are correct on both counts. Will change both assuming that they are still there in the next version.

Thanks,

Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20180130/bdb914b3/attachment.html>


More information about the nio-dev mailing list