This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
The following commit(s) were added to refs/heads/master by this push: new e0892e0f5 [IO-872] PathUtils.directoryAndFileContentEquals doesn't work across FileSystems e0892e0f5 is described below commit e0892e0f565141d7769e69b4490b1c0b4ffc0a73 Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Fri Apr 4 10:11:01 2025 -0400 [IO-872] PathUtils.directoryAndFileContentEquals doesn't work across FileSystems - Fix test - Internal reuse --- src/main/java/org/apache/commons/io/file/PathUtils.java | 6 +++--- .../java/org/apache/commons/io/file/PathUtilsContentEqualsTest.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/apache/commons/io/file/PathUtils.java b/src/main/java/org/apache/commons/io/file/PathUtils.java index c2be28788..21a82d540 100644 --- a/src/main/java/org/apache/commons/io/file/PathUtils.java +++ b/src/main/java/org/apache/commons/io/file/PathUtils.java @@ -1736,10 +1736,10 @@ public static BigInteger sizeOfDirectoryAsBigInteger(final Path directory) throw return countDirectoryAsBigInteger(directory).getByteCounter().getBigInteger(); } - private static Path stripTrailingSeparator(final Path cdir) { - final Path dir = cdir.normalize(); + private static Path stripTrailingSeparator(final Path path) { + final Path dir = path.normalize(); final String separator = dir.getFileSystem().getSeparator(); - final String fileName = Objects.toString(dir.getFileName(), null); + final String fileName = getFileNameString(dir); return fileName != null && fileName.endsWith(separator) ? dir.resolveSibling(fileName.substring(0, fileName.length() - 1)) : dir; } diff --git a/src/test/java/org/apache/commons/io/file/PathUtilsContentEqualsTest.java b/src/test/java/org/apache/commons/io/file/PathUtilsContentEqualsTest.java index 71c3adb05..6b008cac3 100644 --- a/src/test/java/org/apache/commons/io/file/PathUtilsContentEqualsTest.java +++ b/src/test/java/org/apache/commons/io/file/PathUtilsContentEqualsTest.java @@ -163,8 +163,8 @@ public void testDirectoryAndFileContentEqualsDifferentFileSystemsZipVsZipEmpty() Files.copy(emptyZip, zipCopy, StandardCopyOption.REPLACE_EXISTING); try (FileSystem fileSystem1 = FileSystems.newFileSystem(emptyZip, null); FileSystem fileSystem2 = FileSystems.newFileSystem(zipCopy, null)) { - final Path dir1 = fileSystem1.getPath(""); - final Path dir2 = fileSystem2.getPath(""); + final Path dir1 = fileSystem1.getPath("/"); + final Path dir2 = fileSystem2.getPath("/"); // WindowsPath, UnixPath, and ZipPath equals() methods always return false if the argument is not of the same instance as itself. assertTrue(PathUtils.directoryAndFileContentEquals(dir1, dir2)); }