RFR: JDK-8262958 (fs) UnixUserDefinedFileAttributeView cleanup
Sebastian Stenzel
github.com+1204330+overheadhunter at openjdk.java.net
Fri Mar 26 15:05:36 UTC 2021
`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)`.
-------------
Commit messages:
- Merge branch 'master' into JDK-8262958
- renamed variable
- Stream.toList() is already unmodifiable
- deduplicated flistxattr-related code
Changes: https://git.openjdk.java.net/jdk/pull/2916/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2916&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8262958
Stats: 95 lines in 1 file changed: 19 ins; 57 del; 19 mod
Patch: https://git.openjdk.java.net/jdk/pull/2916.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/2916/head:pull/2916
PR: https://git.openjdk.java.net/jdk/pull/2916
More information about the nio-dev
mailing list