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 ----------
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 ----------
- duplicates
-
JDK-8295753 (fs) UnixPath::toRealPath does not return correct case when links not followed
-
- Resolved
-