diff --git a/core/src/main/java/com/datastrato/gravitino/catalog/CatalogManager.java b/core/src/main/java/com/datastrato/gravitino/catalog/CatalogManager.java index e1a9fc41413..87e36036eca 100644 --- a/core/src/main/java/com/datastrato/gravitino/catalog/CatalogManager.java +++ b/core/src/main/java/com/datastrato/gravitino/catalog/CatalogManager.java @@ -162,7 +162,7 @@ public void close() { classLoader.withClassLoader( cl -> { if (catalog != null) { - catalog.ops().close(); + catalog.close(); } catalog = null; return null; diff --git a/core/src/main/java/com/datastrato/gravitino/connector/BaseCatalog.java b/core/src/main/java/com/datastrato/gravitino/connector/BaseCatalog.java index 1bddc754e5f..3f4fdb24144 100644 --- a/core/src/main/java/com/datastrato/gravitino/connector/BaseCatalog.java +++ b/core/src/main/java/com/datastrato/gravitino/connector/BaseCatalog.java @@ -13,6 +13,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.collect.Maps; +import java.io.Closeable; +import java.io.IOException; import java.util.Map; import java.util.Optional; import org.slf4j.Logger; @@ -32,7 +34,7 @@ */ @Evolving public abstract class BaseCatalog - implements Catalog, CatalogProvider, HasPropertyMetadata { + implements Catalog, CatalogProvider, HasPropertyMetadata, Closeable { private static final Logger LOG = LoggerFactory.getLogger(BaseCatalog.class); // This variable is used as a key in properties of catalogs to inject custom operation to @@ -153,6 +155,14 @@ public CatalogOperations ops() { return ops; } + @Override + public void close() throws IOException { + if (ops != null) { + ops.close(); + ops = null; + } + } + public Capability capability() { if (capability == null) { synchronized (this) {