HADOOP-13599. s3a close() to be non-synchronized, so avoid risk of deadlock on shutdown. Contributed by Steve Loughran.
(cherry picked from commit47f80922dc
) (cherry picked from commit1f1e47e411
)
This commit is contained in:
parent
7467628d43
commit
b7b06a5f34
|
@ -127,6 +127,7 @@ public class S3AFileSystem extends FileSystem {
|
|||
private S3AInputPolicy inputPolicy;
|
||||
private static final AtomicBoolean warnedOfCoreThreadDeprecation =
|
||||
new AtomicBoolean(false);
|
||||
private final AtomicBoolean closed = new AtomicBoolean(false);
|
||||
|
||||
// The maximum number of entries that can be deleted in any call to s3
|
||||
private static final int MAX_ENTRIES_TO_DELETE = 1000;
|
||||
|
@ -1514,7 +1515,11 @@ public class S3AFileSystem extends FileSystem {
|
|||
* @throws IOException IO problem
|
||||
*/
|
||||
@Override
|
||||
public synchronized void close() throws IOException {
|
||||
public void close() throws IOException {
|
||||
if (closed.getAndSet(true)) {
|
||||
// already closed
|
||||
return;
|
||||
}
|
||||
try {
|
||||
super.close();
|
||||
} finally {
|
||||
|
|
|
@ -401,6 +401,14 @@ public class TestS3AConfiguration {
|
|||
awsConf.getUserAgent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCloseIdempotent() throws Throwable {
|
||||
conf = new Configuration();
|
||||
fs = S3ATestUtils.createTestFileSystem(conf);
|
||||
fs.close();
|
||||
fs.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and returns a field from an object using reflection. If the field
|
||||
* cannot be found, is null, or is not the expected type, then this method
|
||||
|
|
Loading…
Reference in New Issue