Integrated: JDK-8260966 (fs) Consolidate Linux and macOS implementations of UserDefinedFileAttributeView

Sebastian Stenzel github.com+1204330+overheadhunter at openjdk.java.net
Tue Mar 2 14:44:56 UTC 2021


On Wed, 17 Feb 2021 08:41:43 GMT, Sebastian Stenzel <github.com+1204330+overheadhunter at openjdk.org> wrote:

> Deduplicated code in these classes:
> - `LinuxUserDefinedAttributeView` + `BsdUserDefinedAttributeView` → `UnixUserDefinedAttributeView`. Due to different supported length of attribute names, I added an abstract method `UnixUserDefinedAttributeView.maxNameLength()`.
> - `LinuxNativeDispatcher` + `BsdNativeDispatcher` → `UnixNativeDispatcher`. I basically just moved the Linux implementation up to Unix and added preprocessor directives to distinguish Linux/BSD/Other. Others will throw ENOTSUP UnixExceptions.
> - `LinuxFileStore.isExtendedAttributesEnabled()` + `BsdFileStore.isExtendedAttributesEnabled()` → `UnixFileStore.isExtendedAttributesEnabled()`
> 
> For the latter I introduced `UnixConstants.XATTR_NOT_FOUND`, which is `ENODATA` on Linux and `ENOATTR` on BSD. Note that `UnixConstants.ENODATA` is still present, as @AlanBateman "would prefer if we left ENODATA so that it can be used in Linux specific code" (Quote from https://github.com/openjdk/jdk/pull/2363#issuecomment-772534587)
> 
> This also fixes `Files.copy(src, dst, StandardCopyOption.COPY_ATTRIBUTES)` on macOS/BSD. Previosly an [invocation was missing](https://github.com/openjdk/jdk/blob/jdk-17%2B7/src/java.base/macosx/classes/sun/nio/fs/BsdFileSystem.java#L70-L72).
> 
> I plan to add further commits to clean up this code, once the deduplication is reviewed.

This pull request has now been integrated.

Changeset: 0de6abd4
Author:    Sebastian Stenzel <sebastian.stenzel at skymatic.de>
Committer: Alan Bateman <alanb at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/0de6abd4
Stats:     1159 lines in 16 files changed: 171 ins; 968 del; 20 mod

8260966: (fs) Consolidate Linux and macOS implementations of UserDefinedFileAttributeView
8260691: (fs) LinuxNativeDispatcher should link to xattr functions

Reviewed-by: alanb

-------------

PR: https://git.openjdk.java.net/jdk/pull/2604


More information about the nio-dev mailing list