Files.isWritable and SUBST drives on Windows 7

Christian Schlichtherle christian at schlichtherle.de
Mon Feb 10 01:51:49 PST 2014


Am 10.02.2014 um 10:14 schrieb Alan Bateman <Alan.Bateman at oracle.com>:

> I don't know how your library is using isWritable but if the file is opened immediately after checking that it is writable then it might be best to drop the isWritable check. This would avoid race conditions (file being replaced or changing permissions) and would likely be a bit faster too.

The affected libraries are TrueZIP and TrueVFS. The check is done to decide whether an archive file (e.g. a ZIP file) needs to get mounted read-only or read/write-able. It’s part of a strategy pattern, so different implementations control the behavior. The actual file opening happens lazily within these implementations, so the separate check is required.

I am aware of the potential racing condition. This is acceptable however because if some other party would mess with the archive file concurrently then the results will be undefined anyway.

Regards,
Christian Schlichtherle

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://mail.openjdk.java.net/pipermail/nio-discuss/attachments/20140210/b1477b67/signature.asc 


More information about the nio-discuss mailing list