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

Files.newDirectoryStream on mounted VHD volumes throws NoSuchFileException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 17, 21
    • core-libs
    • None
    • x86_64
    • windows

      The following exception is thrown when Files.newDirectoryStream is invoked on Windows with mounted VHD volumes (https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/dd323654(v=vs.85)):

      C:\Users\user\test>jdk-21\bin\java TestVHD
      Exception in thread "main" java.nio.file.NoSuchFileException: C:\Users\user\test\mount
          at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
          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.WindowsDirectoryStream.<init>(WindowsDirectoryStream.java:86)
          at java.base/sun.nio.fs.WindowsFileSystemProvider.newDirectoryStream(WindowsFileSystemProvider.java:541)
          at java.base/java.nio.file.Files.newDirectoryStream(Files.java:481)
          at TestVHD.main(TestVHD.java:7)

      How to reproduce:

      1. Create and mount a VHD volume
       - run Disk Management tool (diskmgmt.msc)
       - Action > Create VHD
         the following attributes were specified
             Location: C:\Users\user\test\disk.vhd
             Virtual hard dsik size: 100Mb
       - Initilize Disk
       - New Simple Volume
         the following attributes were specified
             Mount in the following empty NTFS folder: C:\Users\user\test\mount

      2. Compile and run the following code:

           import java.io.IOException;
           import java.nio.file.Files;
           import java.nio.file.Path;
           
           public class TestVHD {
               public static void main(String[] args) throws IOException {
                   Files.newDirectoryStream(Path.of("C:\Users\user\test\mount"));
               }
           }

      The issue was observed on 21-ea+5-271
      It is also reproduced with 17

      Please note content of the path C:\Users\user\test\mount is accessible for read-write by system (and 3-d party) tools e.g. Notepad, File Explorer, Far...

            bpb Brian Burkhalter
            vprovodin Vitaly Provodin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: