HQebupt commented on a change in pull request #13904:
URL: https://github.com/apache/pulsar/pull/13904#discussion_r790123939



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -4414,24 +4414,20 @@ protected void handleTopicPolicyException(String 
methodName, Throwable thr, Asyn
     }
 
     protected void internalTruncateNonPartitionedTopic(AsyncResponse 
asyncResponse, boolean authoritative) {
-        Topic topic;
-        try {
-            validateAdminAccessForTenant(topicName.getTenant());
-            validateTopicOwnership(topicName, authoritative);
-            topic = getTopicReference(topicName);
-        } catch (Exception e) {
-            log.error("[{}] Failed to truncate topic {}", clientAppId(), 
topicName, e);
-            resumeAsyncResponseExceptionally(asyncResponse, e);
-            return;
-        }
-        CompletableFuture<Void> future = topic.truncate();
-        future.thenAccept(a -> {
-            asyncResponse.resume(new 
RestException(Response.Status.NO_CONTENT.getStatusCode(),
-                    Response.Status.NO_CONTENT.getReasonPhrase()));
-        }).exceptionally(e -> {
-            asyncResponse.resume(e);
-            return null;
-        });
+        CompletableFuture.supplyAsync(()->{

Review comment:
       The `validateAdminAccessForTenant` method does not contain async method 
in PulsarWebResource. Do you mean this ?
   ```
   protected void internalTruncateNonPartitionedTopic(AsyncResponse 
asyncResponse, boolean authoritative) {
           validateAdminAccessForTenant(topicName.getTenant());
           validateTopicOwnershipAsync(topicName, authoritative)
                   .thenCompose(__ -> getTopicReferenceAsync(topicName))
                   .thenCompose(topic -> topic.truncate())
                   .thenAccept(__ -> {
                       asyncResponse.resume(new 
RestException(Response.Status.NO_CONTENT.getStatusCode(),
                               Response.Status.NO_CONTENT.getReasonPhrase()));
                   }).exceptionally(e -> {
                       // add log here
                       asyncResponse.resume(e);
                       return null;
                   });
       }
   ```




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