RFR: 8368156: java/nio/file/Files/IsSameFile.java failing (win)
Volkan Yazici
vyazici at openjdk.org
Tue Sep 23 07:17:31 UTC 2025
On Mon, 22 Sep 2025 22:08:30 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Use try-with-resources to ensure that the FileSystem `zipfs` is closed when no longer needed. This fixes the issue at hand. Other changes are to simplify cleanup of test files.
test/jdk/java/nio/file/Files/IsSameFile.java line 28:
> 26: * @summary Test of Files.isSameFile
> 27: * @library .. /test/lib
> 28: * @build IsSameFile jdk.test.lib.util.FileUtils
Test target is not necessary to be included in the `@build`:
Suggestion:
* @build jdk.test.lib.util.FileUtils
test/jdk/java/nio/file/Files/IsSameFile.java line 72:
> 70: @BeforeAll
> 71: public void init() throws IOException {
> 72: Path cwd = Path.of(System.getProperty("user.dir"));
There are several places where this idiom is guarded against the absence of the `user.dir` property:
Suggestion:
Path cwd = Path.of(System.getProperty("user.dir", "."));
I leave it up to you.
test/jdk/java/nio/file/Files/IsSameFile.java line 73:
> 71: public void init() throws IOException {
> 72: Path cwd = Path.of(System.getProperty("user.dir"));
> 73: home = Files.createTempDirectory(cwd, "TestISameFile");
Suggestion:
home = Files.createTempDirectory(cwd, "TestIsSameFile");
You can also opt for `TestIsSameFile.class.getSimpleName()` to make the code IDE-refactoring-prone.
test/jdk/java/nio/file/Files/IsSameFile.java line 87:
> 85: }
> 86:
> 87: public void deleteFiles() throws IOException {
I see that `deleteFiles()` is invoked at methods provided to `@MethodSource`s. Maybe you can remove _all_ invocations of `deleteFiles()` and instead simply annotate `deleteFiles()` with `@BeforeEach`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27440#discussion_r2371373199
PR Review Comment: https://git.openjdk.org/jdk/pull/27440#discussion_r2371365589
PR Review Comment: https://git.openjdk.org/jdk/pull/27440#discussion_r2371360925
PR Review Comment: https://git.openjdk.org/jdk/pull/27440#discussion_r2371384327
More information about the nio-dev
mailing list