hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cnaur...@apache.org
Subject [3/3] hadoop git commit: HADOOP-13599. s3a close() to be non-synchronized, so avoid risk of deadlock on shutdown. Contributed by Steve Loughran.
Date Wed, 28 Sep 2016 23:26:29 GMT
HADOOP-13599. s3a close() to be non-synchronized, so avoid risk of deadlock on shutdown. Contributed
by Steve Loughran.

(cherry picked from commit 47f80922dc7cb2fa6d084e6fb1f354c4ec1d4c69)
(cherry picked from commit 1f1e47e41198760b0ddddceb489f2de2b569f38a)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b7b06a5f
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b7b06a5f
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b7b06a5f

Branch: refs/heads/branch-2.8
Commit: b7b06a5f3425f5ca6c34e5d0ac60105aae61a899
Parents: 7467628
Author: Chris Nauroth <cnauroth@apache.org>
Authored: Wed Sep 28 15:53:17 2016 -0700
Committer: Chris Nauroth <cnauroth@apache.org>
Committed: Wed Sep 28 16:21:10 2016 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java    | 7 ++++++-
 .../java/org/apache/hadoop/fs/s3a/TestS3AConfiguration.java  | 8 ++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/b7b06a5f/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java
b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java
index 0c5e569..a7e36e4 100644
--- a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java
+++ b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java
@@ -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 {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b7b06a5f/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/TestS3AConfiguration.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/TestS3AConfiguration.java
b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/TestS3AConfiguration.java
index 3f9a99f..99934a5 100644
--- a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/TestS3AConfiguration.java
+++ b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/TestS3AConfiguration.java
@@ -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


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message