Skip to content

Commit

Permalink
Fix compatibility w/ Hadoop 1 (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
hongyegong authored Aug 7, 2020
1 parent 474ab07 commit c746958
Showing 1 changed file with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public FileStatus[] listStatus(Path f) throws FileNotFoundException, IOException
FileStatus[] result = new FileStatus[fileStatuses.size()];
for (int i = 0; i < fileStatuses.size(); i++) {
// Clone FileStatus objects because they are mutable and Hadoop actually can modify them
result[i] = new FileStatus(fileStatuses.get(i));
result[i] = newFileStatus(fileStatuses.get(i));
}
return result;
}
Expand All @@ -127,7 +127,7 @@ public FileStatus getFileStatus(Path f) throws IOException {
String.format("Path '%s' (qualified: '%s') does not exist.", f, qualifiedPath));
}
// Clone FileStatus object because it is mutable and Hadoop actually can modify it
return new FileStatus(fileStatus);
return newFileStatus(fileStatus);
}

// Below are unsupported methods that are not used in 'globStatus' calls
Expand Down Expand Up @@ -188,4 +188,24 @@ public void setWorkingDirectory(Path newDir) {
public boolean mkdirs(Path f, FsPermission permission) throws IOException {
throw new UnsupportedOperationException();
}

private static FileStatus newFileStatus(FileStatus fileStatus) {
FsPermission fsPermission = fileStatus.getPermission();
return new FileStatus(
fileStatus.getLen(),
fileStatus.isDir(),
fileStatus.getReplication(),
fileStatus.getBlockSize(),
fileStatus.getModificationTime(),
fileStatus.getAccessTime(),
fsPermission == null
? null
: new FsPermission(
fsPermission.getUserAction(),
fsPermission.getGroupAction(),
fsPermission.getOtherAction()),
fileStatus.getOwner(),
fileStatus.getGroup(),
fileStatus.getPath());
}
}

0 comments on commit c746958

Please sign in to comment.