mattisonchao commented on a change in pull request #13897:
URL: https://github.com/apache/pulsar/pull/13897#discussion_r792291657



##########
File path: 
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/PulsarAuthorizationProvider.java
##########
@@ -283,59 +282,45 @@ public void initialize(ServiceConfiguration conf, 
PulsarResources pulsarResource
         }
 
         String topicUri = topicName.toString();
-        CompletableFuture<Void> future = 
pulsarResources.getNamespaceResources()
+        return pulsarResources.getNamespaceResources()
                 .setPoliciesAsync(topicName.getNamespaceObject(), policies -> {
                     policies.auth_policies.getTopicAuthentication()
                             .computeIfAbsent(topicUri, __ -> new HashMap<>())
                             .put(role, actions);
                     return policies;
-                }).thenRun(() -> {
-                    log.info("[{}] Successfully granted access for role {}: {} 
- topic {}", role, role, actions,
-                            topicUri);
+                }).whenComplete((__, throwable) -> {
+                    if (throwable != null) {
+                        log.error("[{}] Failed to set permissions for role {} 
on topic {}", role, role, topicName,
+                                throwable.getCause());

Review comment:
       Hi @michaeljmarshall 
   
   Sorry to confuse you.
   I think It's ok to use ``getCause`` or not when logging.
   
   If we use it, we will get the stack trace like :
   
   ```java
   java.util.concurrent.CompletionException: java.lang.IllegalArgumentException
        at 
java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
        at 
java.base/java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:683)
        at 
java.base/java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:658)
        at 
java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2094)
        at Scratch.main(scratch_3.java:6)
   Caused by: java.lang.IllegalArgumentException
   ```
   
   Without ``getCause`` : 
   
   ```java
   java.lang.IllegalArgumentException
        at Scratch.lambda$main$0(scratch_3.java:7)
        at 
java.base/java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:680)
        at 
java.base/java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:658)
        at 
java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2094)
        at Scratch.main(scratch_3.java:6)
   ``` 
   




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