[EXTERNAL] Re: RFR(S): JDK-8232092 - Support for Windows drives created using subst
Nhat Nguyen
honguye at microsoft.com
Mon Aug 24 20:22:21 UTC 2020
Hi Alan and Brian,
Thank you for the feedback. I have incorporated your suggestions in this new
version of the test [1]. I have also added the test case described in JDK-8213216 [2]
as well. The test case for JDK-8213216 together with three other ones require
administrator privileges to run since they create symlinks; so I have disabled
them by default. Suggestions to further improve the test would be greatly
appreciated.
Additionally, I have found another issue that is related to JDK-8232092 [3].
The setup is quite involved, so I'll just explain it below.
1) create a mount point C:\mount to another drive following this instruction:
https://docs.microsoft.com/en-us/windows-server/storage/disk-management/assign-a-mount-point-folder-path-to-a-drive
2) run `subst T: C:\mount` in an elevated prompt
3) run the following test in an elevated prompt as well
```
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class Test {
public static void main(String[] args) throws IOException {
Path substDrive = Path.of("T:");
Path tempDirectory = Path.of("C:", "mount");
Path tempFile = Files.createTempFile(substDrive, "prefix", "suffix");
Path link = Path.of(substDrive.toString(), "link");
Files.createSymbolicLink(link, tempFile.toAbsolutePath());
System.out.println(Files.isWritable(link));
System.out.println(
Files.isWritable(Path.of(tempDirectory.toString(),
tempFile.getFileName().toString())));
System.out.println(Files.isWritable(tempFile));
Files.delete(tempFile);
Files.delete(link);
}
}
```
The output of the test is true, true, and false; the cause is that the last
call to isWritable also fails at createFromPath in WindowsFileStore::create,
but this time with a different error code (ERROR_DIRECTORY). If we handle this
error and expand the path, we will have the expected result (true, true, true).
I understand that is a very convoluted test and probably doesn't reflect
real-world applications, but this exposes another scenario where the current
code can fail as you mentioned.
[1] webrev: http://cr.openjdk.java.net/~adityam/nhat/subst_drives/1/
[2]: https://bugs.openjdk.java.net/browse/JDK-8213216
[3]: https://bugs.openjdk.java.net/browse/JDK-8232092
More information about the nio-dev
mailing list