RFR: 8349812: (fs) Files.newByteChannel with empty path name and CREATE_NEW throws unexpected exception [v2]

Maxim Kartashev mkartashev at openjdk.org
Thu Feb 13 10:24:11 UTC 2025


On Wed, 12 Feb 2025 21:50:08 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> I extended the test a bit. Have a look, please.
>
> There is now a failure on Windows:
> 
> java.nio.file.AccessDeniedException: 
> 	at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
> 	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
> 	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
> 	at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:231)
> 	at java.base/java.nio.file.Files.newByteChannel(Files.java:357)
> 	at java.base/java.nio.file.Files.newByteChannel(Files.java:399)
> 	at SBC.emptyPathTest(SBC.java:444)
> 	at SBC.main(SBC.java:66)

Indeed, on Windows the WinAPI function used to open a file (`CreateFileW`) will return `ERROR_ACCESS_DENIED` when used on a directory _without_ a special flag (`FILE_FLAG_BACKUP_SEMANTICS`). This flag is not specified in this particular code path. I will make the necessary changes to the test.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23560#discussion_r1954227606


More information about the nio-dev mailing list