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

(fs) Path.toRealPath(LinkOption.NOFOLLOW_LINKS) produces unexpected result (OS X)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8u25
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      os_x

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      OS X 10.9.5

      A DESCRIPTION OF THE PROBLEM :
      java.nio.file.Path.toRealPath(LinkOption.NOFOLLOW_LINKS) produces a wrong result on Mac. It returns the original path of the file, not the real one.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      The following JUnit test fails with junit.framework.ComparisonFailure: expected:</tmp/[Test.TXT]> but was:</tmp/[test.txt]>

      public class PathTest extends TestCase {
          public void testToRealPath() throws Exception {
              String filename = "/tmp/Test.TXT";
              File file = new File(filename);
              file.createNewFile();
              file = new File(file.toString().toLowerCase());
              assertEquals(filename, file.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS).toString());
          }
      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The test is expected to pass.
      ACTUAL -
      The test fails with junit.framework.ComparisonFailure: expected:</tmp/[Test.TXT]> but was:</tmp/[test.txt]>

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.File;
      import java.nio.file.LinkOption;
      import junit.framework.TestCase;

      public class PathTest extends TestCase {
          public void testToRealPath() throws Exception {
              String filename = "/tmp/Test.TXT";
              File file = new File(filename);
              file.createNewFile();
              file = new File(file.toString().toLowerCase());
              assertEquals(filename, file.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS).toString());
          }
      }


      ---------- END SOURCE ----------

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated: