(fs) Files.newByteChannel with empty path name and CREATE_NEW throws unexpected exception

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 25
    • Affects Version/s: 21, 25
    • Component/s: core-libs
    • None
    • b11
    • linux

      The following snippet is supposed to throw FileAlreadyExistsException when it tries to open the current directory for writing with the "create new" option also set:
      OpenOption[] opts = { WRITE, CREATE_NEW };
      Files.newByteChannel(Path.of(""), opts);

      However, on Linux, it throws an unexpected ArrayIndexOutOfBoundsException with the stack trace looking like

      at java.base/sun.nio.fs.UnixChannelFactory.open(UnixChannelFactory.java:203)
      at java.base/sun.nio.fs.UnixChannelFactory.newFileChannel(UnixChannelFactory.java:133)
      at java.base/sun.nio.fs.UnixChannelFactory.newFileChannel(UnixChannelFactory.java:146)
      at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:216)

            Assignee:
            Maxim Kartashev
            Reporter:
            Maxim Kartashev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: