Skip to content

Commit e0892e0

Browse files
committed
[IO-872] PathUtils.directoryAndFileContentEquals doesn't work across
FileSystems - Fix test - Internal reuse
1 parent b95421c commit e0892e0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/main/java/org/apache/commons/io/file/PathUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,10 +1736,10 @@ public static BigInteger sizeOfDirectoryAsBigInteger(final Path directory) throw
17361736
return countDirectoryAsBigInteger(directory).getByteCounter().getBigInteger();
17371737
}
17381738

1739-
private static Path stripTrailingSeparator(final Path cdir) {
1740-
final Path dir = cdir.normalize();
1739+
private static Path stripTrailingSeparator(final Path path) {
1740+
final Path dir = path.normalize();
17411741
final String separator = dir.getFileSystem().getSeparator();
1742-
final String fileName = Objects.toString(dir.getFileName(), null);
1742+
final String fileName = getFileNameString(dir);
17431743
return fileName != null && fileName.endsWith(separator) ? dir.resolveSibling(fileName.substring(0, fileName.length() - 1)) : dir;
17441744
}
17451745

src/test/java/org/apache/commons/io/file/PathUtilsContentEqualsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ public void testDirectoryAndFileContentEqualsDifferentFileSystemsZipVsZipEmpty()
163163
Files.copy(emptyZip, zipCopy, StandardCopyOption.REPLACE_EXISTING);
164164
try (FileSystem fileSystem1 = FileSystems.newFileSystem(emptyZip, null);
165165
FileSystem fileSystem2 = FileSystems.newFileSystem(zipCopy, null)) {
166-
final Path dir1 = fileSystem1.getPath("");
167-
final Path dir2 = fileSystem2.getPath("");
166+
final Path dir1 = fileSystem1.getPath("/");
167+
final Path dir2 = fileSystem2.getPath("/");
168168
// WindowsPath, UnixPath, and ZipPath equals() methods always return false if the argument is not of the same instance as itself.
169169
assertTrue(PathUtils.directoryAndFileContentEquals(dir1, dir2));
170170
}

0 commit comments

Comments
 (0)