From 32ef6a78c9eeaa7e4331a541aa90efb2733a0434 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Tue, 21 Jul 2026 12:00:29 +0000 Subject: [PATCH] 8388046: (fs) UnixFileSystem Flags.failIfUnableToCopyPosix and Flags.failIfUnableToCopyNonPosix no longer needed Reviewed-by: alanb --- .../classes/sun/nio/fs/BsdFileSystem.java | 4 +--- .../classes/sun/nio/fs/UnixFileSystem.java | 18 ++---------------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/java.base/macosx/classes/sun/nio/fs/BsdFileSystem.java b/src/java.base/macosx/classes/sun/nio/fs/BsdFileSystem.java index 69a5d775b0b..1772b295fed 100644 --- a/src/java.base/macosx/classes/sun/nio/fs/BsdFileSystem.java +++ b/src/java.base/macosx/classes/sun/nio/fs/BsdFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -132,8 +132,6 @@ class BsdFileSystem extends UnixFileSystem { try { chown(target, attrs.uid(), attrs.gid()); } catch (UnixException x) { - if (flags.failIfUnableToCopyPosix) - x.rethrowAsIOException(target); } return; } diff --git a/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java b/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java index 8a2c2bb27e8..c6cdb274ccd 100644 --- a/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java +++ b/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -389,10 +389,8 @@ abstract class UnixFileSystem boolean copyPosixAttributes; boolean copyNonPosixAttributes; - // flags that indicate if we should fail if attributes cannot be copied + // flag that indicates if we should fail if basic attributes cannot be copied boolean failIfUnableToCopyBasic; - boolean failIfUnableToCopyPosix; - boolean failIfUnableToCopyNonPosix; static Flags fromCopyOptions(CopyOption... options) { Flags flags = new Flags(); @@ -483,10 +481,6 @@ abstract class UnixFileSystem dfd = open(target, O_RDONLY, 0); } catch (UnixException x) { // access to target directory required to copy named attributes - if (flags.copyNonPosixAttributes && flags.failIfUnableToCopyNonPosix) { - try { rmdir(target); } catch (UnixException ignore) { } - x.rethrowAsIOException(target); - } } boolean done = false; @@ -503,8 +497,6 @@ abstract class UnixFileSystem } } catch (UnixException x) { // unable to set owner/group - if (flags.failIfUnableToCopyPosix) - x.rethrowAsIOException(target); } } // copy other attributes @@ -513,8 +505,6 @@ abstract class UnixFileSystem try { sfd = open(source, O_RDONLY, 0); } catch (UnixException x) { - if (flags.failIfUnableToCopyNonPosix) - x.rethrowAsIOException(source); } if (sfd >= 0) { source.getFileSystem().copyNonPosixAttributes(sfd, dfd); @@ -663,8 +653,6 @@ abstract class UnixFileSystem fchown(fo, attrs.uid(), attrs.gid()); fchmod(fo, attrs.mode()); } catch (UnixException x) { - if (flags.failIfUnableToCopyPosix) - x.rethrowAsIOException(target); } } // copy non POSIX attributes (depends on file system) @@ -749,8 +737,6 @@ abstract class UnixFileSystem chown(target, attrs.uid(), attrs.gid()); chmod(target, attrs.mode()); } catch (UnixException x) { - if (flags.failIfUnableToCopyPosix) - x.rethrowAsIOException(target); } } if (flags.copyBasicAttributes) {