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

NTFS junction points are not detected by Files.readAttributes()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 7u45
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.7.0_45"
      Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
      Java HotSpot(TM) Client VM (build 24.45-b08, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [???????????? 5.1.2600]
      (Win XP Pro SP3 x86 RUS)

      A DESCRIPTION OF THE PROBLEM :
      I am having an NTFS junction point E:\TMP\2gis that links to D:\Programs\2gis. Windows DIR command recognises it corretly and shows it as 23.12.2013 23:56 <JUNCTION> 2gis

      However, when I try to java.nio.file.Files.readAttributes on this Path, it is seen as a regular directory.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      I run the following code:

      Path path = Paths.get("E:\\TMP\\2gis");
      BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
      System.out.printf(
      "symlink=%b
      dir=%b
      other=%b
      file=%b",
      attrs.isSymbolicLink(), attrs.isDirectory(), attrs.isOther(), attrs.isRegularFile() );


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Either attrs.isSymbolicLink() or attrs.isOther() should be true
      ACTUAL -
      symlink=false
      dir=true
      other=false
      file=false

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      import java.nio.file.Files;
      import java.nio.file.attribute.BasicFileAttributes;
      import java.nio.file.Path;
      import java.nio.file.Paths;

      public class Test {

      public static void main(String[] args) {
      try {
      Path path = Paths.get("E:\\TMP\\2gis");
      BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
      System.out.printf(
        "symlink=%b
      dir=%b
      other=%b
      file=%b",
        attrs.isSymbolicLink(), attrs.isDirectory(), attrs.isOther(), attrs.isRegularFile() );
      } catch(java.io.IOException e) {
      }
      }
      }
      ---------- END SOURCE ----------

            alanb Alan Bateman
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: