World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#2525] fix(catalog-hive): Fix classNotFoundError in the Caffeine removal listener (#2600)
Qi Yuf139f4977775
diff --git a/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/CachedClientPool.java b/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/CachedClientPool.javaindex c68545a7e9..9b2c4371fc 100644--- a/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/CachedClientPool.java+++ b/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/CachedClientPool.java@@ -135,6 +135,13 @@ public class CachedClientPool implements ClientPool<IMetaStoreClient, TException}public void close() {+ // Close all the HiveClientPool instances in the cache first and then shutdown the scheduler. As+ // Removal listener in Cache will be invoked by the scheduler asynchronously, we need to close+ // the HiveClientPool instances first and then shutdown the scheduler. Another reason is that+ // Caller may call this `close` method and then close the class loader that is needed by the+ // `close` method. We must ensure that all the HiveClientPool instances are closed before the+ // class loader is closed.+ clientPoolCache.asMap().forEach((key, value) -> value.close());clientPoolCache.invalidateAll();scheduler.shutdownNow();}diff --git a/core/src/main/java/com/datastrato/gravitino/utils/ClientPoolImpl.java b/core/src/main/java/com/datastrato/gravitino/utils/ClientPoolImpl.javaindex 0976dded47..ac07cc6b9b 100644--- a/core/src/main/java/com/datastrato/gravitino/utils/ClientPoolImpl.java+++ b/core/src/main/java/com/datastrato/gravitino/utils/ClientPoolImpl.java@@ -36,7 +36,7 @@ public abstract class ClientPoolImpl<C, E extends Exception>private final Object signal = new Object();private final boolean retryByDefault;private volatile int currentSize;- private boolean closed;+ private volatile boolean closed;protected ClientPoolImpl(int poolSize, Class<? extends E> reconnectExc, boolean retryByDefault) {this.poolSize = poolSize;@@ -89,6 +89,12 @@ public abstract class ClientPoolImpl<C, E extends Exception>@Overridepublic void close() {+ // To avoid closing it repeatedly, we add a judgment that if it has been closed,+ // we do not need to close it anymore.+ if (closed) {+ return;+ }+this.closed = true;try {while (currentSize > 0) {