Skip to content

FileUtils.copyFile in 3.1.0 fails on second invocation if Windows read-only flag is set on the source file #38

Closed as not planned
@awallgren

Description

@awallgren

FileUtils.copyFile was changed to use the NIO Files.copy call a while back. Files.copy is invoked with the COPY_ATTRIBUTES and REPLACE_EXISTING attributes (which makes sense).

However, on Windows, COPY_ATTRIBUTES preserves the read-only flag if it's set on the source file, BUT REPLACE_EXISTING fails with an AccessDeniedException exception if the destinations' read-only attribute is set.

This is problematic because it breaks existing builds when updating from maven-war-plugin:3.1.0 to maven-war-plugin-3.2.0 (which switch from plexus-utils-3.0.24 to plexus-utils-3.1.0) where the SCM uses the read-only flag for unmodified files, e.g. Perforce.

TBH, I'm not sure where I come down on whether this is a bug in the JDK (REPLACE_EXISTING doesn't) or plexus-utils (using COPY_ATTRIBUTES may include attributes that make subsequent invocations with REPLACE_EXISTING to fail in a platform-specific way).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions