This is an automated email from the ASF dual-hosted git repository. roryqi pushed a commit to branch ISSUE-6353 in repository https://gitbox.apache.org/repos/asf/gravitino.git
commit d3ccbe9b44ebe260b7807c6be255004d63919873 Author: roryqi <[email protected]> AuthorDate: Wed Jan 15 19:21:09 2025 +0800 [#6245] fix(authz): Authorization should use classloader to create the plugin (#6246) ### What changes were proposed in this pull request? Authorization should use classloader to create the plugin ### Why are the changes needed? Fix: #6245 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? I tested it manually. --- .../main/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 14b1912b4d..444e89062a 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 abstract class BaseCatalog<T extends BaseCatalog> 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);
