gnodet-bot commented on code in PR #401:
URL: https://github.com/apache/maven-filtering/pull/401#discussion_r4103253676
##########
src/main/java/org/apache/maven/shared/filtering/FilteringUtils.java:
##########
@@ -298,6 +298,13 @@ static boolean isEmpty(final String string) {
*/
public static void copyFile(Path from, Path to, String encoding,
FilterWrapper[] wrappers, boolean overwrite)
throws IOException {
+ // If the destination is a symbolic link (dangling or pointing to a
regular file left by an
+ // earlier build that used NOFOLLOW_LINKS), delete it before writing
so that the output is
+ // always a regular file and CachingOutputStream / CachingWriter do
not fail with
+ // NoSuchFileException when trying to follow a dangling link.
+ if (Files.isSymbolicLink(to)) {
+ Files.delete(to);
Review Comment:
Clean and minimal fix. Note that `Files.isSymbolicLink` does not throw if
`to` doesn't exist (returns `false`), so this is safe for the first-write case
too. 👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]