Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Duplicate
-
2.6.0
-
None
-
None
Description
This came out of discussion in HADOOP-12718. The FileSystem#listStatus contract does not indicate null is a valid return and some callers do not test null before use:
AbstractContractGetFileStatusTest#testListStatusEmptyDirectory:
assertEquals("ls on an empty directory not of length 0", 0,
fs.listStatus(subfolder).length);
ChecksumFileSystem#copyToLocalFile:
FileStatus[] srcs = listStatus(src);
for (FileStatus srcFile : srcs) {
SimpleCopyLIsting#getFileStatus:
FileStatus[] fileStatuses = fileSystem.listStatus(path); if (excludeList != null && excludeList.size() > 0) { ArrayList<FileStatus> fileStatusList = new ArrayList<>(); for(FileStatus status : fileStatuses) {
IMHO, there is no good reason for listStatus to return null. It should throw IOExceptions upon errors or return empty list.
To enforce the contract that null is an invalid return, update javadoc and leverage @Nullable/@NotNull/@Nonnull annotations.
So far, I am only aware of the following functions that can return null:
- RawLocalFileSystem#listStatus
Attachments
Attachments
Issue Links
- duplicates
-
HADOOP-7352 FileSystem#listStatus should throw IOE upon access error
- Resolved
- is depended upon by
-
HADOOP-12718 Incorrect error message by fs -put local dir without permission
- Resolved