You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by st...@apache.org on 2022/10/18 14:29:29 UTC

[hadoop] branch branch-3.3 updated: HADOOP-18476. Abfs and S3A FileContext bindings to close wrapped filesystems in finalizer (#4966)

This is an automated email from the ASF dual-hosted git repository.

stevel pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.3 by this push:
     new 7a18ceb2692 HADOOP-18476. Abfs and S3A FileContext bindings to close wrapped filesystems in finalizer (#4966)
7a18ceb2692 is described below

commit 7a18ceb2692cf01edd7bc11bb023f752958295b1
Author: Steve Loughran <st...@cloudera.com>
AuthorDate: Tue Oct 18 14:53:02 2022 +0100

    HADOOP-18476. Abfs and S3A FileContext bindings to close wrapped filesystems in finalizer (#4966)
    
    This is to try and close the underlying filesystems when the FileContext APIs are used.
    Without this, threads may be leaked
    
    Contributed by Steve Loughran
---
 .../src/main/java/org/apache/hadoop/fs/s3a/S3A.java         | 13 +++++++++++--
 .../src/main/java/org/apache/hadoop/fs/azurebfs/Abfs.java   |  9 +++++++++
 .../src/main/java/org/apache/hadoop/fs/azurebfs/Abfss.java  |  9 +++++++++
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3A.java b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3A.java
index 78643cc5e04..ec433fa95c2 100644
--- a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3A.java
+++ b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3A.java
@@ -33,10 +33,10 @@ import java.net.URISyntaxException;
  */
 @InterfaceAudience.Public
 @InterfaceStability.Evolving
-public class S3A extends DelegateToFileSystem{
+public class S3A extends DelegateToFileSystem {
 
   public S3A(URI theUri, Configuration conf)
-          throws IOException, URISyntaxException {
+      throws IOException, URISyntaxException {
     super(theUri, new S3AFileSystem(), conf, "s3a", false);
   }
 
@@ -54,4 +54,13 @@ public class S3A extends DelegateToFileSystem{
     sb.append('}');
     return sb.toString();
   }
+
+  /**
+   * Close the file system; the FileContext API doesn't have an explicit close.
+   */
+  @Override
+  protected void finalize() throws Throwable {
+    fsImpl.close();
+    super.finalize();
+  }
 }
diff --git a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/Abfs.java b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/Abfs.java
index 32df9422386..e595b2f4efa 100644
--- a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/Abfs.java
+++ b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/Abfs.java
@@ -43,4 +43,13 @@ public class Abfs extends DelegateToFileSystem {
   public int getUriDefaultPort() {
     return -1;
   }
+
+  /**
+   * Close the file system; the FileContext API doesn't have an explicit close.
+   */
+  @Override
+  protected void finalize() throws Throwable {
+    fsImpl.close();
+    super.finalize();
+  }
 }
diff --git a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/Abfss.java b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/Abfss.java
index c33265ce324..ba20bbb5d76 100644
--- a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/Abfss.java
+++ b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/Abfss.java
@@ -43,4 +43,13 @@ public class Abfss extends DelegateToFileSystem {
   public int getUriDefaultPort() {
     return -1;
   }
+
+  /**
+   * Close the file system; the FileContext API doesn't have an explicit close.
+   */
+  @Override
+  protected void finalize() throws Throwable {
+    fsImpl.close();
+    super.finalize();
+  }
 }


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