From 7acf81744cd5737c9e38f5c402a5f59d901d63ad Mon Sep 17 00:00:00 2001 From: Rory Date: Wed, 15 Jan 2025 14:53:19 +0800 Subject: [PATCH] [#6245] fix(authz): Authorization should use classloader to create the plugin --- .../java/org/apache/gravitino/connector/BaseCatalog.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 14b1912b4d6..444e89062a6 100644 --- a/core/src/main/java/org/apache/gravitino/connector/BaseCatalog.java +++ b/core/src/main/java/org/apache/gravitino/connector/BaseCatalog.java @@ -208,8 +208,15 @@ public void initAuthorizationPluginInstance(IsolatedClassLoader classLoader) { 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. authorizationPlugin = - authorization.newPlugin(entity.namespace().level(0), provider(), this.conf); + classLoader.withClassLoader( + cl -> + 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);