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 — [MSHARED-1176] Test case for NoSuchFileException while copying symbolic by kwin · Pull Request #110 · apache/maven-shared-utils

Conversation

@kwin

@kwin kwin commented Jul 26, 2022

Copy link
Copy Markdown
Member

link with relative non-existing target

Sorry, something went wrong.

Uh oh!

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

All reactions
@kwin
kwin marked this pull request as draft July 26, 2022 17:39
@kwin

kwin commented Jul 26, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

@slawekjaranowski This depends on #109 being merged first otherwise the build breaks even before executing the unit test.

Update: Done and rebased this PR.

All reactions

Sorry, something went wrong.

Uh oh!

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

@michael-o

michael-o commented Jul 26, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Without testing your PR, here is what I see on FreeBSD (FreeBSD bsd1srv.fritz.box 12.3-STABLE FreeBSD 12.3-STABLE GENERIC amd64) where chmod -h works as expected:

mosipov@bsd1srv:/usr/home/mosipov/var/Projekte/maven-shared-utils (master =)
$ grep chmod /tmp/out
fchmod(188,0100644)                              = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/org/apache/maven/shared/utils/annotations.xml",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/org/apache/maven/shared/utils/annotations.xml",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/META-INF/LICENSE",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/META-INF/LICENSE",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/META-INF/DEPENDENCIES",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/META-INF/DEPENDENCIES",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/META-INF/NOTICE",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/META-INF/NOTICE",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/directory1/file1.txt",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/directory1/file1.txt",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/directory2/directory21/file21.txt",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/directory2/directory21/file21.txt",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/directory2/file2.txt",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/directory2/file2.txt",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/file.txt",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/file.txt",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/expand/expand_test.zip",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/expand/expand_test.zip",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/targetDir/targetFile.txt",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/targetDir/targetFile.txt",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/fileR.txt",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/fileR.txt",0644) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside",0644) ERR#2 'No such file or directory'

and

mosipov@bsd1srv:/usr/home/mosipov/var/Projekte/maven-shared-utils (master =)
$ grep symLinkToFileOnTheOutside /tmp/out
fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside",0x7fffdfffc1f0,0x0) ERR#2 'No such file or directory'
fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside",{ mode=lrwxr-xr-x ,inode=91832,size=19,blksize=131072 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
unlink("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside") = 0 (0x0)
fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside",0x7fffdfffc460,0x0) ERR#2 'No such file or directory'
fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=lrwxr-xr-x ,inode=91158,size=19,blksize=131072 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
readlink("/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside","../onTheOutside.txt",1025) = 19 (0x13)
access("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside",F_OK) ERR#2 'No such file or directory'
symlink("../onTheOutside.txt","/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside") = 0 (0x0)
fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside",0644) ERR#2 'No such file or directory'

The symlink or its target does not exist.

All reactions

Sorry, something went wrong.

Uh oh!

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

@kwin

kwin commented Jul 26, 2022

Copy link
Copy Markdown
Member Author

Yes, exactly. In this case the target does not (yet) exist. The question is how FileUtils.copyFile(...) should behave in that case.

All reactions

Sorry, something went wrong.

Uh oh!

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

@kwin
[MSHARED-1112] Test case for NoSuchFileException while copying symbolic
da11090
link with relative non-existing target
@kwin
kwin force-pushed the bugfix/MSHARED-1112-nsfe-on-symlink-copy branch from 94fa38a to da11090 Compare July 26, 2022 18:00
@michael-o

michael-o commented Jul 26, 2022

Copy link
Copy Markdown
Member

I'll try to look into this this month.

All reactions

Sorry, something went wrong.

Uh oh!

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

@kwin

kwin commented Jul 26, 2022

Copy link
Copy Markdown
Member Author

IMHO copy should also not fail in case the source symlink is broken (which it currently does)

All reactions

Sorry, something went wrong.

Uh oh!

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

@michael-o

michael-o commented Jul 26, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

IMHO copy should also not fail in case the source symlink is broken (which it currently does)

I agree with that. If source leads to nowhere then dest should do too. Fully valid with POSIX.

All reactions

Sorry, something went wrong.

Uh oh!

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

@kwin
Add test for symbolic link whose target does not even exist for the
8ff14a5
source symlink file
@kwin

kwin commented Jul 27, 2022

Copy link
Copy Markdown
Member Author

IMHO copy should also not fail in case the source symlink is broken (which it currently does)

I added another (failing) test case for this scenario in 8ff14a5

All reactions

Sorry, something went wrong.

Uh oh!

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

@michael-o

michael-o commented Jul 27, 2022

Copy link
Copy Markdown
Member

From my PoV, it should mimic cp(1).

All reactions

Sorry, something went wrong.

Uh oh!

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

@kwin kwin changed the title [MSHARED-1112] Test case for NoSuchFileException while copying symbolic [MSHARED-1176] Test case for NoSuchFileException while copying symbolic Jan 1, 2023
kwin
kwin commented Jan 1, 2023
View reviewed changes
Comment thread src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java Resolved

Uh oh!

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

@kwin
Update src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java
ab4ca12
michael-o
michael-o requested changes Jan 1, 2023
View reviewed changes
Comment thread src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java
tempFolder.newFolder( "destDirectory" ),
"toSymLink"
);
// this creates a symlink in a new folder pointing to a non-existing relative target "./target.txt"

@michael-o michael-o Jan 1, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

directory, not folder

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java
"toSymLink"
);
// this creates a symlink in a new folder pointing to a non-existing relative target "./non-existing.txt"
FileUtils.copyFile( from.toFile(), to, null, (FileUtils.FilterWrapper[]) null );

@michael-o michael-o Jan 1, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

directory, not folder

Sorry, something went wrong.

Uh oh!

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

All reactions
@jira-importer jira-importer mentioned this pull request Aug 3, 2022
[MSHARED-899] Upgrade commons-io to 2.7 #293
Closed
@jira-importer

jira-importer commented Jul 3, 2025

Copy link
Copy Markdown

Resolve #306

All reactions

Sorry, something went wrong.

Uh oh!

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

@slachiewicz slachiewicz added the bug Something isn't working label Feb 1, 2026
slachiewicz
slachiewicz approved these changes Feb 6, 2026
View reviewed changes
@slachiewicz

slachiewicz commented Feb 6, 2026

Copy link
Copy Markdown
Member

@kwin feel free to merge it if it is still relevant

All reactions

Sorry, something went wrong.

Uh oh!

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

@slachiewicz slachiewicz closed this Sep 10, 2026
@jira-importer jira-importer mentioned this pull request Sep 11, 2026
[MSHARED-1176] FileUtils.copyFile should support copying symlinks with non-existing targets #306
Closed
@slachiewicz slachiewicz mentioned this pull request Sep 11, 2026
Copy a symbolic link even when its target does not exist #433
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@michael-o michael-o michael-o requested changes
@slachiewicz slachiewicz slachiewicz approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

bug Something isn't working

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

4 participants

@kwin @michael-o @jira-importer @slachiewicz
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.