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

(fs) FileStore does not support DFS file share paths (win)

    XMLWordPrintable

Details

    • generic
    • generic

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 11 Enterprise
      Version 22H2
      OS build 22621.3593
      Experience Windows Feature Experience Pack 1000.22700.1003.0

      JDK 21.0.3

      A DESCRIPTION OF THE PROBLEM :
      I have a network drive \\foo\bar\baz mounted to drive letter O.

      It seems I get the correct results when I use the FileStore API with "O:\\" as the path, and incorrect results when using "\\foo\bar\baz" as the path.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Mount a network drive by UNC path:

      net use o: \\foo\bar\baz /persist:yes


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect the same values in both cases.

      Absolute path | Usable space (bytes) | Total space (bytes) | File store name
      O:\ | 718622703616 | 4612657508352 | MX Prodn
      \\foo\bar\baz | 718622703616 | 4612657508352 | MX Prodn

      ACTUAL -
      Absolute path | Usable space (bytes) | Total space (bytes) | File store name
      O:\ | 718622703616 | 4612657508352 | MX Prodn
      \\foo\bar\baz | 56672243712 | 81744883712 |


      ---------- BEGIN SOURCE ----------
      import java.nio.file.FileStore;
      import java.nio.file.Files;
      import java.nio.file.Path;
      import java.nio.file.Paths;
      import java.util.List;

      class Scratch {

          private static final String FORMAT = "%-40s | %20s | %20s | %15s%n";

          public static void main(String[] args) {

              final List<String> paths = List.of(
                  "O:\\",
                  "\\\\foo\\bar\\baz"
              );

              System.out.printf(FORMAT,
                      "Absolute path",
                      "Usable space (bytes)", "Total space (bytes)",
                      "File store name");

              paths.forEach(Scratch::processPath);
          }

              private static void processPath(String pathStr) {
              try {
                  Path path = Paths.get(pathStr);
                  FileStore fileStore = Files.getFileStore(path);
                  System.out.printf(FORMAT,
                          pathStr,
                          fileStore.getUsableSpace(),
                          fileStore.getTotalSpace(),
                          fileStore.name());
              } catch (Exception e) {
                  System.out.printf("Unable to get file store for '%s': %s%n", pathStr, e.getMessage());
              }
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


      Attachments

        Activity

          People

            bpb Brian Burkhalter
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: