diff --git a/WHATSNEW b/WHATSNEW index 92f1c5096..68b2ccfea 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -19,6 +19,8 @@ Other changes: * AntClassLoader now implements the ClassLoader#findResource(String) method. Github Pull Request #150 + * Ant tries to avoid file name canonicalization whne possible. + Bugzilla Report 65499 Changes from Ant 1.10.10 TO Ant 1.10.11 ======================================= diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java b/src/main/org/apache/tools/ant/util/FileUtils.java index d835438fe..52c662541 100644 --- a/src/main/org/apache/tools/ant/util/FileUtils.java +++ b/src/main/org/apache/tools/ant/util/FileUtils.java @@ -1421,10 +1421,21 @@ public class FileUtils { if (f1 == null || f2 == null) { return false; } + return fileNameEquals(f1, f2) || isSameFile(f1, f2); + } + + private boolean isSameFile(File f1, File f2) throws IOException { + if (f1.exists()) { + try { + return f2.exists() && Files.isSameFile(f1.toPath(), f2.toPath()); + } catch (NoSuchFileException e) { + // file has been removed between exists check and isSameFile? + return false; + } + } File f1Normalized = normalize(f1.getAbsolutePath()); File f2Normalized = normalize(f2.getAbsolutePath()); - return f1Normalized.equals(f2Normalized) - || f1Normalized.getCanonicalFile().equals(f2Normalized + return f1Normalized.getCanonicalFile().equals(f2Normalized .getCanonicalFile()); }