diff --git a/underfs/swift/src/main/java/alluxio/underfs/swift/SwiftUnderFileSystem.java b/underfs/swift/src/main/java/alluxio/underfs/swift/SwiftUnderFileSystem.java index 4c22dca188dd..9a13ad4b1bd9 100644 --- a/underfs/swift/src/main/java/alluxio/underfs/swift/SwiftUnderFileSystem.java +++ b/underfs/swift/src/main/java/alluxio/underfs/swift/SwiftUnderFileSystem.java @@ -385,7 +385,8 @@ private boolean copy(String src, String dst) { * @throws IOException if an error occurs listing the directory */ private boolean isDirectory(String path) throws IOException { - String[] children = listInternal(path, true); + String strippedPath = stripPrefixIfPresent(path); + String[] children = listInternal(strippedPath, true); return children != null && children.length > 0; } @@ -406,11 +407,11 @@ private String[] listInternal(String path, boolean recursive) throws IOException Directory directory = new Directory(path, '/'); Container c = mAccount.getContainer(mContainerName); Collection res = c.listDirectory(directory); - Set children = new HashSet<>(); + Set children = new HashSet(); Iterator iter = res.iterator(); while (iter.hasNext()) { - DirectoryOrObject dirObj = iter.next(); - String child = stripFolderSuffixIfPresent(dirObj.getName()); + DirectoryOrObject dirobj = (DirectoryOrObject) iter.next(); + String child = stripFolderSuffixIfPresent(dirobj.getName()); String noPrefix = stripPrefixIfPresent(child, path); children.add(noPrefix); }