-
Notifications
You must be signed in to change notification settings - Fork 42
bug fix: silently fails overwriting symlinks #12
base: trunk
Are you sure you want to change the base?
Conversation
When A is an existing symlink to B, then createSymbolicLink(A,C) does neither overwrite A->B by A->C (as expected in analogy to the behavior of copy(A,C)) nor does it throw an exception nor does it return A->B to indicate the failure, but it actually "silently fails", i. e. it returns A->C! This certainly is heavily problematic, unsymmetric to what copy(File,File) and Files.createSymbolicLink(Path,Path) do, and certainly unwanted and buggy behavior. The solution is to delete any existing target before creating the symlic, hence copying the behavior of copy(File,File).
Do we have JIRA issue for that ? I don't see a reference in the PR. If i think about that. Is it possible to identify this situation and produce a warning or error ? And what about a test ? |
Opened JIRA MNG-6048 to describe this issue. I could change to code to add a warning, but it would make the code less stable, as the solution currently uses an atomic OS operation (delete if exists), while splitting in two operations (if exists then delete) imposes the situation of a stale delete in case somebody else removed the file in-between. About tests: Do you always add an integration test for each bug or is this a particular demand for this very bug report? |
Interesting issue. How does |
Yes,
|
Just read and your code. This is a good idea but some things are still don't clear. If |
Based on this, I get this result on FreeBS 11.0-RELEASE:
|
I think this discussion deviates a bit too far from the origin: The current code silently fails, so the caller assumes the link was overwritten, while it is not. That is what I solved. Not more. What you ask for is a different feature: Do not overwrite existing files and links without explicit grant. Feel free to open a different feature proposal for that. :-) |
Committers: If there is any reason why my contribution is not considered for merge, then please tell me, but do not further stay silent. |
Thinking about this one more time, I do think that we should fail just like |
@michael-o @khmarbaise Any news? |
This is a fix MNG-6048
When A is an existing symlink to B, then createSymbolicLink(A,C) does
neither overwrite A->B by A->C (as expected in analogy to the behavior
of copy(A,C)) nor does it throw an exception nor does it return A->B to
indicate the failure, but it actually "silently fails", i. e. it returns
A->C!
This certainly is heavily problematic, unsymmetric to what
copy(File,File) and Files.createSymbolicLink(Path,Path) do, and
certainly unwanted and buggy behavior.
The solution is to delete any existing target before creating the
symlic, hence copying the behavior of copy(File,File).