Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8349812

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 25
    • 21, 25
    • 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)

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

              Created:
              Updated:
              Resolved: