yuqi1129 commented on code in PR #6717:
URL: https://github.com/apache/gravitino/pull/6717#discussion_r2002765001


##########
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerAuthorizationPlugin.java:
##########
@@ -786,7 +786,7 @@ private void createRangerServiceIfNecessary(Map<String, 
String> config, String s
     try {
       rangerClient.getService(serviceName);
     } catch (RangerServiceException rse) {
-      if (rse.getStatus().equals(ClientResponse.Status.NOT_FOUND)) {
+      if (ClientResponse.Status.NOT_FOUND.equals(rse.getStatus())) {

Review Comment:
   Does the change here aim to resolve the NEP problem for 
`res.getSatus().equals`?



##########
core/src/main/java/org/apache/gravitino/hook/CatalogHookDispatcher.java:
##########
@@ -82,21 +85,26 @@ public Catalog createCatalog(
 
     Catalog catalog = dispatcher.createCatalog(ident, type, provider, comment, 
properties);
 
-    // Set the creator as the owner of the catalog.
-    OwnerManager ownerManager = GravitinoEnv.getInstance().ownerManager();
-    if (ownerManager != null) {
-      ownerManager.setOwner(
-          ident.namespace().level(0),
-          NameIdentifierUtil.toMetadataObject(ident, 
Entity.EntityType.CATALOG),
-          PrincipalUtils.getCurrentUserName(),
-          Owner.Type.USER);
-    }
+    try {
+      // Set the creator as the owner of the catalog.
+      OwnerManager ownerManager = GravitinoEnv.getInstance().ownerManager();
+      if (ownerManager != null) {
+        ownerManager.setOwner(
+            ident.namespace().level(0),
+            NameIdentifierUtil.toMetadataObject(ident, 
Entity.EntityType.CATALOG),
+            PrincipalUtils.getCurrentUserName(),
+            Owner.Type.USER);
+      }
 
-    // Apply the metalake securable object privileges to authorization plugin
-    FutureGrantManager futureGrantManager = 
GravitinoEnv.getInstance().futureGrantManager();
-    if (futureGrantManager != null && catalog instanceof BaseCatalog) {
-      futureGrantManager.grantNewlyCreatedCatalog(
-          ident.namespace().level(0), (BaseCatalog) catalog);
+      // Apply the metalake securable object privileges to authorization plugin
+      FutureGrantManager futureGrantManager = 
GravitinoEnv.getInstance().futureGrantManager();
+      if (futureGrantManager != null && catalog instanceof BaseCatalog) {
+        futureGrantManager.grantNewlyCreatedCatalog(
+            ident.namespace().level(0), (BaseCatalog) catalog);
+      }
+    } catch (Exception e) {
+      LOG.warn("Fail to execute the post hook operations, rollback the catalog 
" + ident, e);
+      dispatcher.dropCatalog(ident, true);

Review Comment:
   I have the following issues that are not very clear:
   1.  Why do we need to remove `dispatcher.dropCatalog(ident, true);` once 
there are exceptions? can you add more description about the reasons? 
   2.  Did other entities like schema, table, etc. need to be modified?



-- 
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