RFR: 8286160: (fs) Files.exists returns unexpected results with C:\pagefile.sys because it's not readable

Alan Bateman alanb at openjdk.java.net
Tue Jun 7 15:54:59 UTC 2022


On Tue, 7 Jun 2022 15:48:32 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> 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?

checkReadAccess comes later, when !w & !x.

-------------

PR: https://git.openjdk.java.net/jdk/pull/9045


More information about the nio-dev mailing list