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
This commit is contained in:
Steve Loughran 2022-10-18 14:53:02 +01:00
parent 193e042dd0
commit 84404257c1
No known key found for this signature in database
GPG Key ID: D22CF846DBB162A0
3 changed files with 29 additions and 2 deletions

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}