public static List<FileStatus> listStatusWithStatusFilter(final FileSystem fs, final Path dir,
    final FileStatusFilter filter) throws IOException {
    FileStatus[] status = null;
    try {
      status = fs.listStatus(dir);
    } catch (FileNotFoundException fnfe) {
      LOG.trace("{} does not exist", dir);
      return null;
    }

    if (ArrayUtils.getLength(status) == 0) {
      return null;
    }

    if (filter == null) {
      return Arrays.asList(status);
    } else {
      List<FileStatus> status2 = filterFileStatuses(status, filter);
      if (status2 == null || status2.isEmpty()) {
        return null;
      } else {
        return status2;
      }
    }
  }
Calls fs.listStatus() and treats FileNotFoundException as non-fatal This accommodates
differences between hadoop versions, where hadoop 1 does not throw a FileNotFoundException, and
return an empty FileStatus[] while Hadoop 2 will throw FileNotFoundException.
@param fs     file system
@param dir    directory
@param filter file status filter
@return null if dir is empty or doesn't exist, otherwise FileStatus list
hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java