Skip to content

Commit

Permalink
[#3673] fix(core): avoid to initialize catalog ops when closing catal…
Browse files Browse the repository at this point in the history
…og (#3672)

### What changes were proposed in this pull request?

avoid to initialize catalog ops when closing catalog

### Why are the changes needed?

Fix: #3673 

### Does this PR introduce _any_ user-facing change?

no

### How was this patch tested?

no
  • Loading branch information
mchades authored May 31, 2024
1 parent 4a3ac04 commit 5a4d8d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void close() {
classLoader.withClassLoader(
cl -> {
if (catalog != null) {
catalog.ops().close();
catalog.close();
}
catalog = null;
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,7 +34,7 @@
*/
@Evolving
public abstract class BaseCatalog<T extends 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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 5a4d8d2

Please sign in to comment.