RFR: 8356127: (fs) UnixFileSystemProvider.implDelete could save a syscall in some cases [v3]
Alan Bateman
alanb at openjdk.org
Fri May 9 06:22:53 UTC 2025
On Thu, 8 May 2025 20:10:09 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Modify `UnixFileSystemProvider.implDelete` to attempt first to delete the file using `unlink` and, if that fails, fall back to using `rmdir` if the file is a directory.
>
> Brian Burkhalter has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
>
> - 8356127: Change capability naming
> - Merge
> - 8356127: Add capability check for EISDIR
> - 8356127: (fs) UnixFileSystemProvider.implDelete could save a syscall in some cases
src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java line 260:
> 258: // check whether the file is a directory
> 259: if (e.errno() == EISDIR ||
> 260: UnixFileAttributes.get(file, false).isDirectory())
If unlink fails (not EISDIR) then shouldn't we just throw the error? I'm not sure why it attempts to stat the file for this case.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25107#discussion_r2081008315
More information about the nio-dev
mailing list