RFR: 8286160: (fs) Files.exists returns unexpected results with C:\pagefile.sys because it's not readable
Brian Burkhalter
bpb at openjdk.java.net
Tue Jun 7 15:54:59 UTC 2022
On Tue, 7 Jun 2022 09:29:37 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> If in `WindosFileSystemProvider.checkAccess(Path obj, AccessMode... modes)` the sub-test `checkReadAccess(WindowsPath)` fails and no modes are specified, then try to determine file existence by reading the file's attributes.
>
> src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java line 395:
>
>> 393: }
>> 394: throw ioe;
>> 395: }
>
> Testing the existence of a file is performance issue in some usages and would be interesting to see if this would be a bit better.
>
>
> // check file exists only
> if (!r && !w && !x) {
> file.checkRead();
> try {
> WindowsFileAttributes.get(file, true);
> return;
> } catch (WindowsException e) {
> exc.rethrowAsIOException(file);
> }
> }
That was actually my first draft version. What happened to `checkReadAccess()` here?
-------------
PR: https://git.openjdk.java.net/jdk/pull/9045
More information about the nio-dev
mailing list