This is an automated email from the ASF dual-hosted git repository.
jshao pushed a commit to branch branch-0.8
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/branch-0.8 by this push:
new 08d3e1e75d [#6245] fix(authz): Authorization should use classloader to
create the plugin (#6258)
08d3e1e75d is described below
commit 08d3e1e75d17e72a0cd7dbf09215e2c7ca25deed
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Jan 15 20:34:09 2025 +0800
[#6245] fix(authz): Authorization should use classloader to create the
plugin (#6258)
### 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.
Co-authored-by: roryqi <[email protected]>
---
.../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);