diff --git a/paimon-common/src/main/java/org/apache/paimon/client/ClientPool.java b/paimon-common/src/main/java/org/apache/paimon/client/ClientPool.java index c42a30b35310..6d0feec64dba 100644 --- a/paimon-common/src/main/java/org/apache/paimon/client/ClientPool.java +++ b/paimon-common/src/main/java/org/apache/paimon/client/ClientPool.java @@ -26,7 +26,7 @@ import java.util.function.Supplier; /** Client pool for using multiple clients to execute actions. */ -public interface ClientPool { +public interface ClientPool extends Closeable { /** Action interface with return object for client. */ interface Action { R run(C client) throws E; @@ -42,7 +42,7 @@ interface ExecuteAction { void execute(ExecuteAction action) throws E, InterruptedException; /** Default implementation for {@link ClientPool}. */ - abstract class ClientPoolImpl implements Closeable, ClientPool { + abstract class ClientPoolImpl implements ClientPool { private volatile LinkedBlockingDeque clients; diff --git a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java index a590ede6d2e6..052325e48635 100644 --- a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java +++ b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java @@ -1017,7 +1017,7 @@ public void repairTable(Identifier identifier) throws TableNotExistException { @Override public void close() throws Exception { - // do nothing + clients.close(); } @Override diff --git a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/pool/CachedClientPool.java b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/pool/CachedClientPool.java index f1d09e297b45..7e3b45a5e0ae 100644 --- a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/pool/CachedClientPool.java +++ b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/pool/CachedClientPool.java @@ -204,6 +204,14 @@ static Key extractKey(String clientClassName, String cacheKeys, Configuration co return Key.of(elements); } + @Override + public void close() throws IOException { + if (clientPoolCache != null) { + clientPoolCache.asMap().values().forEach(HiveClientPool::close); + clientPoolCache.cleanUp(); + } + } + static class Key { private final List elements;