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

Brian Burkhalter bpb at openjdk.org
Wed Feb 12 21:54:26 UTC 2025


On Wed, 12 Feb 2025 10:10:51 GMT, Maxim Kartashev <mkartashev at openjdk.org> wrote:

>> test/jdk/java/nio/file/Files/SBC.java line 433:
>> 
>>> 431:             Files.newByteChannel(Path.of(""), opts);
>>> 432:             throw new RuntimeException("FileAlreadyExistsException expected");
>>> 433:         } catch (FileAlreadyExistsException x) { }
>> 
>> While WRITE + CREATE_NEW are the options to tickle the bug, I think emptyPathTest should be expanded to test over combinations of open options. There are several code paths with options such as O_NOFOLLOW and DELETE_ON_CLOSE that will also need to be tested.
>
> 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)

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

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


More information about the nio-dev mailing list