From b669a0b6e47b86f5d7ba0078529f81236e741eec 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. --- .../java/org/apache/gravitino/connector/BaseCatalog.java | 8 ++------ 1 file changed, 2 insertions(+), 6 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..fa7bb75fa76 100644 --- a/core/src/main/java/org/apache/gravitino/connector/BaseCatalog.java +++ b/core/src/main/java/org/apache/gravitino/connector/BaseCatalog.java @@ -205,12 +205,8 @@ 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 ->