Copilot commented on code in PR #13834:
URL: https://github.com/apache/gravitino/pull/13834#discussion_r4260991820


##########
core/src/main/java/org/apache/gravitino/hook/MetalakeHookDispatcher.java:
##########
@@ -122,7 +126,11 @@ public void disableMetalake(NameIdentifier ident) throws 
NoSuchMetalakeException
   public boolean dropMetalake(NameIdentifier ident) {
     // For metalake, we don't clear all the privileges of catalog 
authorization plugin.
     // we just remove metalake.
-    return dispatcher.dropMetalake(ident);
+    boolean dropped = dispatcher.dropMetalake(ident);
+    if (dropped) {
+      AuthorizationUtils.notifyEntityNameIdMappingChange(ident, 
Entity.EntityType.METALAKE);
+    }
+    return dropped;
   }

Review Comment:
   The same `dropped` + notification pattern is duplicated in both 
`dropMetalake` overloads. To reduce the chance of future divergence (e.g., one 
path updated without the other), consider extracting a small private helper 
(e.g., `notifyOnDropped(boolean dropped, NameIdentifier ident)`) or routing one 
overload to the other when possible.



##########
core/src/main/java/org/apache/gravitino/hook/MetalakeHookDispatcher.java:
##########
@@ -105,7 +105,11 @@ public boolean dropMetalake(NameIdentifier ident, boolean 
force)
       throws NonEmptyEntityException, MetalakeInUseException {
     // Child catalog/schema/fileset write-through secrets are cleaned when 
MetalakeManager
     // force-drops catalogs via CatalogManager.dropCatalog → 
FilesetCatalogOperations.dropSchema.
-    return dispatcher.dropMetalake(ident, force);
+    boolean dropped = dispatcher.dropMetalake(ident, force);
+    if (dropped) {
+      AuthorizationUtils.notifyEntityNameIdMappingChange(ident, 
Entity.EntityType.METALAKE);
+    }
+    return dropped;
   }

Review Comment:
   The same `dropped` + notification pattern is duplicated in both 
`dropMetalake` overloads. To reduce the chance of future divergence (e.g., one 
path updated without the other), consider extracting a small private helper 
(e.g., `notifyOnDropped(boolean dropped, NameIdentifier ident)`) or routing one 
overload to the other when possible.



##########
server-common/src/test/java/org/apache/gravitino/server/authorization/jcasbin/TestJcasbinAuthorizationCacheKeys.java:
##########
@@ -33,8 +33,7 @@ void testMetadataIdCacheKey() {
     MetadataObject metalake =
         MetadataObjects.of(Collections.singletonList("ml1"), 
MetadataObject.Type.METALAKE);
     Assertions.assertEquals(
-        key("ml1", "METALAKE", ""),
-        JcasbinAuthorizationCacheKeys.metadataIdCacheKey("ml1", metalake));
+        key("ml1", ""), 
JcasbinAuthorizationCacheKeys.metadataIdCacheKey("ml1", metalake));

Review Comment:
   Same as in `TestJcasbinChangePoller`: collapsing this expected/actual 
comparison to one line reduces readability and may break repository formatting 
rules. Consider restoring the multi-line formatting for consistency with the 
rest of the file.



##########
server-common/src/test/java/org/apache/gravitino/server/authorization/jcasbin/TestJcasbinChangePoller.java:
##########
@@ -80,8 +80,7 @@ void testChangeLogFullNameForMetalakeKeepsItself() {
         JcasbinChangeListener.metadataObjectFromChangeLog(
             "ml1", "ml1", MetadataObject.Type.METALAKE);
     Assertions.assertEquals(
-        key("ml1", "METALAKE", ""),
-        JcasbinAuthorizationCacheKeys.metadataIdCacheKey("ml1", metalake));
+        key("ml1", ""), 
JcasbinAuthorizationCacheKeys.metadataIdCacheKey("ml1", metalake));

Review Comment:
   This assertion was reformatted into a single long line, which makes it 
harder to read and is more likely to violate typical Java formatting/checkstyle 
max-line-length rules used elsewhere in this test class. Please wrap the 
`Assertions.assertEquals` arguments across multiple lines similarly to 
surrounding tests.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to