HADOOP-11918. Listing an empty s3a root directory throws FileNotFound. Contributed by Lei (Eddy) Xu.
This commit is contained in:
parent
67b0e967f0
commit
7fe521b1dd
@ -1087,6 +1087,9 @@ Release 2.8.0 - UNRELEASED
|
||||
HADOOP-12252. LocalDirAllocator should not throw NPE with empty string
|
||||
configuration. (Zhihai Xu)
|
||||
|
||||
HADOOP-11918. Listing an empty s3a root directory throws FileNotFound.
|
||||
(Lei (Eddy) Xu via cnauroth)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HADOOP-12051. ProtobufRpcEngine.invoke() should use Exception.toString()
|
||||
|
@ -25,6 +25,7 @@
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.hadoop.fs.FileStatus;
|
||||
|
||||
import static org.apache.hadoop.fs.contract.ContractTestUtils.createFile;
|
||||
import static org.apache.hadoop.fs.contract.ContractTestUtils.dataset;
|
||||
@ -120,4 +121,17 @@ public void testCreateFileOverRoot() throws Throwable {
|
||||
assertIsDirectory(root);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListEmptyRootDirectory() throws IOException {
|
||||
//extra sanity checks here to avoid support calls about complete loss of data
|
||||
skipIfUnsupported(TEST_ROOT_TESTS_ENABLED);
|
||||
FileSystem fs = getFileSystem();
|
||||
Path root = new Path("/");
|
||||
FileStatus[] statuses = fs.listStatus(root);
|
||||
for (FileStatus status : statuses) {
|
||||
ContractTestUtils.assertDeleted(fs, status.getPath(), true);
|
||||
}
|
||||
assertEquals("listStatus on empty root-directory returned a non-empty list",
|
||||
0, fs.listStatus(root).length);
|
||||
}
|
||||
}
|
||||
|
@ -983,6 +983,9 @@ public S3AFileStatus getFileStatus(Path f) throws IOException {
|
||||
|
||||
return new S3AFileStatus(true, false,
|
||||
f.makeQualified(uri, workingDir));
|
||||
} else if (key.isEmpty()) {
|
||||
LOG.debug("Found root directory");
|
||||
return new S3AFileStatus(true, true, f.makeQualified(uri, workingDir));
|
||||
}
|
||||
} catch (AmazonServiceException e) {
|
||||
if (e.getStatusCode() != 404) {
|
||||
|
Loading…
Reference in New Issue
Block a user