Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling of closeables in BasePolarisCatalog #478

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
Expand Down Expand Up @@ -401,13 +400,6 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
MDC.putCloseable("request_id", httpRequest.getHeader("request_id"))) {
chain.doFilter(request, response);
} finally {
Object contextCatalog =
currentCallContext
.contextVariables()
.get(CallContext.REQUEST_PATH_CATALOG_INSTANCE_KEY);
if (contextCatalog instanceof Closeable closeableCatalog) {
closeableCatalog.close();
}
currentCallContext.close();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ public void initialize(String name, Map<String, String> properties) {
CatalogProperties.FILE_IO_IMPL);
}
}
this.closeableGroup = CallContext.getCurrentContext().closeables();
CallContext.getCurrentContext().closeables().addCloseable(this);
this.closeableGroup = new CloseableGroup();
closeableGroup.addCloseable(metricsReporter());
closeableGroup.setSuppressCloseFailure(true);

Expand Down Expand Up @@ -764,7 +765,11 @@ public List<Namespace> listNamespaces(Namespace namespace) throws NoSuchNamespac
}

@Override
public void close() throws IOException {}
public void close() throws IOException {
if (closeableGroup != null) {
closeableGroup.close();
}
}

@Override
public List<TableIdentifier> listViews(Namespace namespace) {
Expand Down