HADOOP-18403. Fix FileSystem leak in ITestS3AAWSCredentialsProvider (#4737)

Contributed By: Viraj Jasani
This commit is contained in:
Viraj Jasani 2022-08-18 15:44:43 -07:00 committed by GitHub
parent b7d4dc61bf
commit 7f030250b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -162,12 +162,15 @@ public void testAnonymousProvider() throws Exception {
conf.set(AWS_CREDENTIALS_PROVIDER,
AnonymousAWSCredentialsProvider.class.getName());
Path testFile = getCSVTestPath(conf);
FileSystem fs = FileSystem.newInstance(testFile.toUri(), conf);
assertNotNull(fs);
assertTrue(fs instanceof S3AFileSystem);
FileStatus stat = fs.getFileStatus(testFile);
assertNotNull(stat);
assertEquals(testFile, stat.getPath());
try (FileSystem fs = FileSystem.newInstance(testFile.toUri(), conf)) {
assertNotNull("S3AFileSystem instance must not be null", fs);
assertTrue("FileSystem must be the instance of S3AFileSystem", fs instanceof S3AFileSystem);
FileStatus stat = fs.getFileStatus(testFile);
assertNotNull("FileStatus with qualified path must not be null", stat);
assertEquals(
"The qualified path returned by getFileStatus should be same as the original file",
testFile, stat.getPath());
}
}
}