RFR: 8267820: (fs) Files.copy should attempt to copy POSIX attributes when target file in custom file system
Alan Bateman
alanb at openjdk.java.net
Sun Feb 27 18:04:48 UTC 2022
On Fri, 25 Feb 2022 23:31:22 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> In `java.nio.file.Files.copy()` copy POSIX attributes even if the target is from a different file system provided both the source and target file systems support such attributes.
src/java.base/share/classes/java/nio/file/CopyMoveHelper.java line 164:
> 162: dstPosixView.setOwner(srcPosixAttrs.owner());
> 163: dstPosixView.setGroup(srcPosixAttrs.group());
> 164: } catch (ProviderMismatchException ignore) {
I don't think setOwner/setGroup can work here. It may be possible to obtain a UserPrincipalLookupService from the target file system and use it to lookup the string representation of the source user/group but it may not be reliable. It's also likely that these setXXX will fail when the target file is on the default file system. Maybe it would be simpler to limit the copying to just POSIX file permissions.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7627
More information about the nio-dev
mailing list