RFR: JDK-8262958 (fs) UnixUserDefinedFileAttributeView cleanup
Alan Bateman
alanb at openjdk.java.net
Tue Mar 30 07:12:37 UTC 2021
On Wed, 10 Mar 2021 16:36:06 GMT, Sebastian Stenzel <github.com+1204330+overheadhunter at openjdk.org> wrote:
> `flistxattr` gets called in two places:
> 1. Obviously during `list()`
> 2. When copying xattr from one file to another using `copyExtendedAttributes()`
>
> Commit 7104008 adds a new private method `List<String> list(int fd, int bufSize) throws UnixException` that takes care of the "retry if buffer too small" logic that previously happened inside of two almost identical for-loops.
>
> In order to properly reuse the same code in both places, I move the stripping of the `USER_NAMESPACE` attr prefix from `asList` to `list()`, which I'd consider an undocumented side effect of the former anyway.
>
> This also significantly reduced complexity in both affected methods, but in turn `copyExtendedAttributes` will now deal with Strings instead of bytes for the attr names. While I am convinced that the benefits outweighs this point, I don't want to leave this unmentioned, as this change might slightly affect performance of `Files.copy(src, dst, StandardCopyOption.COPY_ATTRIBUTES)`.
Marked as reviewed by alanb (Reviewer).
-------------
PR: https://git.openjdk.java.net/jdk/pull/2916
More information about the nio-dev
mailing list