findepi commented on code in PR #122:
URL: https://github.com/apache/polaris/pull/122#discussion_r1729372962


##########
polaris-service/src/main/java/io/polaris/service/admin/PolarisAdminService.java:
##########
@@ -1739,7 +1739,7 @@ private boolean revokePrivilegeOnTableLikeFromRole(
       TableIdentifier identifier,
       PolarisEntitySubType subType,
       PolarisPrivilege privilege) {
-    PolarisEntity catalogEntity =
+    CatalogEntity ignored =

Review Comment:
   That would indeed work, but would raise IllegalArgumentException and the 
code currently throws NotFoundException. If we want such change, i would prefer 
that it's done in a  PR separately from pure code cleanup.
   
   I wish Optional had ifEmpty method (just like it has ifPresent). the closest 
is `ifPresentOrElse`:
   
   ```java
   findCatalogByName(catalogName)
       .ifPresentOrElse(
           ignored -> {},
           () -> {
             throw new NotFoundException("Parent catalog %s not found", 
catalogName);
           });
   ```
   
   it happens that non-functional style is actually shorter
   
   ```java
   al<CatalogEntity> catalog = findCatalogByName(catalogName);
   if (catalog.isEmpty()) {
     throw new NotFoundException("Parent catalog %s not found", catalogName);
   }
   ```
   
   which one would you prefer?
   
   



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