From 71c717a2cc6f07f2b0b1c8024d862f50dc6636ae Mon Sep 17 00:00:00 2001 From: pancx Date: Wed, 15 Jan 2025 17:01:59 +0800 Subject: [PATCH] [#6236] fix(core): fix possible resource leak in BaseCatalog fix possible resource leak in BaseCatalog. --- .../apache/gravitino/connector/BaseCatalog.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/org/apache/gravitino/connector/BaseCatalog.java b/core/src/main/java/org/apache/gravitino/connector/BaseCatalog.java index 444e89062a6..35fd0ba03e2 100644 --- a/core/src/main/java/org/apache/gravitino/connector/BaseCatalog.java +++ b/core/src/main/java/org/apache/gravitino/connector/BaseCatalog.java @@ -205,18 +205,10 @@ public void initAuthorizationPluginInstance(IsolatedClassLoader classLoader) { LOG.info("Authorization provider is not set!"); return; } - try { - BaseAuthorization authorization = - BaseAuthorization.createAuthorization(classLoader, authorizationProvider); - - // Load the authorization plugin with the class loader of the catalog. - // Because the JDBC authorization plugin may load JDBC driver using the class loader. + try (BaseAuthorization authorization = + BaseAuthorization.createAuthorization(classLoader, authorizationProvider)) { authorizationPlugin = - classLoader.withClassLoader( - cl -> - authorization.newPlugin( - entity.namespace().level(0), provider(), this.conf)); - + authorization.newPlugin(entity.namespace().level(0), provider(), this.conf); } catch (Exception e) { LOG.error("Failed to load authorization with class loader", e); throw new RuntimeException(e);