GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Copy a symbolic link even when its target does not exist by slachiewicz · Pull Request #433 · apache/maven-shared-utils

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Sep 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

copyFile(File, File) checked source.exists() before its symbolic-link branch, and File.exists() follows links, so a link whose target is missing was rejected as a missing file. The link branch now runs first. Two smaller gaps in the same path surfaced while testing: the link branch did not create the destination directory the way the regular-file path does, and the filtering overload then tried to copy POSIX permissions onto a dangling link, which follows the link and fails. Both are handled in this change.

The two tests follow the scenarios from #110 by @kwin: a dangling link, and a relative link copied into another directory where its target does not resolve. Both are skipped on Windows like the other symlink tests here.

copyFile is deprecated in favour of Files.copy with NOFOLLOW_LINKS, but it still ships, and maven-filtering hit this same path in MSHARED-1112, so the reordered check is worth having.

Fixes #306.

Verified: mvn -B verify on JDK 17 -> Tests run: 793, Failures: 0, Errors: 0; on master the dangling-link test fails with IOException: File .../dangling does not exist.

This change was created with AI assistance.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@slachiewicz
Copy a symbolic link even when its target does not exist
f5d6028
copyFile(File, File) checked source.exists() before the symbolic-link
branch, and File.exists() follows links, so a dangling link was rejected
as a missing file. The link branch now runs first and creates the
destination directory like the regular-file path does, and the
permission copy is skipped for a link destination because the link has
no permissions of its own and its target may be absent.

Fixes #306
@slachiewicz slachiewicz added this to the 3.5.0 milestone Sep 11, 2026
@slachiewicz slachiewicz added the bug Something isn't working label Sep 11, 2026
@slachiewicz
slachiewicz marked this pull request as ready for review September 11, 2026 07:58
@slachiewicz
slachiewicz requested a review from elharo September 11, 2026 07:58
elharo
elharo approved these changes Sep 11, 2026
View reviewed changes
@slachiewicz
slachiewicz merged commit 23ddeee into master Sep 11, 2026
15 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@slachiewicz
slachiewicz deleted the agent/copyfile-dangling-symlink branch September 11, 2026 14:21
@github-actions github-actions Bot assigned slachiewicz Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@elharo elharo elharo approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@slachiewicz slachiewicz

Labels

bug Something isn't working

Projects

None yet

Milestone

3.5.0

Development

Successfully merging this pull request may close these issues.

[MSHARED-1176] FileUtils.copyFile should support copying symlinks with non-existing targets

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@slachiewicz @elharo
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.