This is an automated email from the ASF dual-hosted git repository.
liuxun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 857a4645d1 [#6245] fix(authz): Authorization should use classloader to
create the plugin (#6246)
857a4645d1 is described below
commit 857a4645d114c55eef9c35815921c656f1fe9887
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);