This is an automated email from the ASF dual-hosted git repository.
yuqi4733 pushed a commit to branch branch-1.1
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/branch-1.1 by this push:
new a2f57d8418 [Cherry-pick to branch-1.1] [#9170] improvement(authz):
Avoid overhead when authorization plugin is empty (#10053) (#10111)
a2f57d8418 is described below
commit a2f57d84181f2a9ee555083ff3c5f83fe9f89032
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Mar 2 17:44:20 2026 +0800
[Cherry-pick to branch-1.1] [#9170] improvement(authz): Avoid overhead when
authorization plugin is empty (#10053) (#10111)
**Cherry-pick Information:**
- Original commit: d97f25fafa5b4ec6969888afc37c127e51a50b5c
- Target branch: `branch-1.1`
- Status: ✅ Clean cherry-pick (no conflicts)
Co-authored-by: roryqi <[email protected]>
---
.../authorization/FutureGrantManager.java | 28 ++++++++++------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git
a/core/src/main/java/org/apache/gravitino/authorization/FutureGrantManager.java
b/core/src/main/java/org/apache/gravitino/authorization/FutureGrantManager.java
index b6aee4b1c8..3b828d9faa 100644
---
a/core/src/main/java/org/apache/gravitino/authorization/FutureGrantManager.java
+++
b/core/src/main/java/org/apache/gravitino/authorization/FutureGrantManager.java
@@ -57,15 +57,20 @@ public class FutureGrantManager {
public void grantNewlyCreatedCatalog(String metalake, BaseCatalog catalog) {
try {
+ AuthorizationPlugin authorizationPlugin =
catalog.getAuthorizationPlugin();
+
+ if (authorizationPlugin == null) {
+ // If the authorization plugin is null, it means the catalog does not
support authorization,
+ // so we can skip the future grant process to avoid overhead.
+ return;
+ }
MetadataObject metalakeObject =
MetadataObjects.of(null, metalake, MetadataObject.Type.METALAKE);
Optional<Owner> ownerOptional = ownerDispatcher.getOwner(metalake,
metalakeObject);
+
ownerOptional.ifPresent(
owner -> {
- AuthorizationPlugin authorizationPlugin =
catalog.getAuthorizationPlugin();
- if (authorizationPlugin != null) {
- authorizationPlugin.onOwnerSet(metalakeObject, null, owner);
- }
+ authorizationPlugin.onOwnerSet(metalakeObject, null, owner);
});
Map<UserEntity, Set<RoleEntity>> userGrantRoles = Maps.newHashMap();
@@ -129,20 +134,13 @@ public class FutureGrantManager {
}
for (Map.Entry<UserEntity, Set<RoleEntity>> entry :
userGrantRoles.entrySet()) {
- AuthorizationPlugin authorizationPlugin =
catalog.getAuthorizationPlugin();
- if (authorizationPlugin != null) {
- authorizationPlugin.onGrantedRolesToUser(
- Lists.newArrayList(entry.getValue()), entry.getKey());
- }
+ authorizationPlugin.onGrantedRolesToUser(
+ Lists.newArrayList(entry.getValue()), entry.getKey());
}
for (Map.Entry<GroupEntity, Set<RoleEntity>> entry :
groupGrantRoles.entrySet()) {
- AuthorizationPlugin authorizationPlugin =
catalog.getAuthorizationPlugin();
-
- if (authorizationPlugin != null) {
- authorizationPlugin.onGrantedRolesToGroup(
- Lists.newArrayList(entry.getValue()), entry.getKey());
- }
+ authorizationPlugin.onGrantedRolesToGroup(
+ Lists.newArrayList(entry.getValue()), entry.getKey());
}
} catch (IOException e) {
throw new RuntimeException(e);