Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ private void visitFileStatus(Path path, boolean recursive, Consumer<FileStatus>
throws IOException {
// _hadoopFS.listFiles(path, false) will not return directories as files, thus use listStatus(path) here.
FileStatus[] files = _hadoopFS.listStatus(path);
if (files == null) {
Comment thread
Akanksha-kedia marked this conversation as resolved.
throw new IOException("FileSystem.listStatus() returned null for path: " + path);
}
for (FileStatus file : files) {
visitor.accept(file);
if (file.isDirectory() && recursive) {
Expand Down Expand Up @@ -234,32 +237,25 @@ public void copyFromLocalDir(File srcFile, URI dstUri)
}

@Override
public boolean isDirectory(URI uri) {
try {
return _hadoopFS.getFileStatus(new Path(uri)).isDirectory();
} catch (IOException e) {
LOGGER.error("Could not get file status for {}", uri, e);
throw new RuntimeException(e);
}
public boolean isDirectory(URI uri)
throws IOException {
return _hadoopFS.getFileStatus(new Path(uri)).isDirectory();
}

@Override
public long lastModified(URI uri) {
try {
return _hadoopFS.getFileStatus(new Path(uri)).getModificationTime();
} catch (IOException e) {
LOGGER.error("Could not get file status for {}", uri, e);
throw new RuntimeException(e);
}
public long lastModified(URI uri)
throws IOException {
return _hadoopFS.getFileStatus(new Path(uri)).getModificationTime();
}

@Override
public boolean touch(URI uri)
throws IOException {
Path path = new Path(uri);
if (!exists(uri)) {
FSDataOutputStream fos = _hadoopFS.create(path);
fos.close();
try (FSDataOutputStream fos = _hadoopFS.create(path)) {
// create an empty file; stream closed by try-with-resources
}
} else {
_hadoopFS.setTimes(path, System.currentTimeMillis(), -1);
}
Expand Down Expand Up @@ -307,7 +303,9 @@ private org.apache.hadoop.conf.Configuration getConf(String hadoopConfPath) {
@Override
public void close()
throws IOException {
_hadoopFS.close();
if (_hadoopFS != null) {
_hadoopFS.close();
}
super.close();
}
}
Loading