leizhiyuan commented on code in PR #15843:
URL: https://github.com/apache/pulsar/pull/15843#discussion_r885117089


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -1003,32 +1006,36 @@ private void 
internalUnloadTransactionCoordinatorAsync(AsyncResponse asyncRespon
                 });
     }
 
-    protected void internalDeleteTopic(boolean authoritative, boolean force) {
+    protected void internalDeleteTopic(AsyncResponse asyncResponse, boolean 
authoritative, boolean force) {
         if (force) {
-            internalDeleteTopicForcefully(authoritative);
+            internalDeleteTopicForcefully(asyncResponse, authoritative);
         } else {
-            internalDeleteTopic(authoritative);
+            internalDeleteTopic(asyncResponse, authoritative);
         }
     }
 
-    protected void internalDeleteTopic(boolean authoritative) {
-        validateNamespaceOperation(topicName.getNamespaceObject(), 
NamespaceOperation.DELETE_TOPIC);
-        validateTopicOwnership(topicName, authoritative);
+    protected void internalDeleteTopic(AsyncResponse asyncResponse, boolean 
authoritative) {
 
-        try {
-            pulsar().getBrokerService().deleteTopic(topicName.toString(), 
false).get();
-            log.info("[{}] Successfully removed topic {}", clientAppId(), 
topicName);
-        } catch (Exception e) {
-            Throwable t = e.getCause();
-            log.error("[{}] Failed to delete topic {}", clientAppId(), 
topicName, t);
-            if (t instanceof TopicBusyException) {
-                throw new RestException(Status.PRECONDITION_FAILED, "Topic has 
active producers/subscriptions");
-            } else if (isManagedLedgerNotFoundException(e)) {
-                throw new RestException(Status.NOT_FOUND, 
getTopicNotFoundErrorMessage(topicName.toString()));
-            } else {
-                throw new RestException(t);
-            }
-        }
+        validateTopicOwnershipAsync(topicName, authoritative).thenCompose(
+                        __ -> 
validateNamespaceOperationAsync(topicName.getNamespaceObject(),
+                                NamespaceOperation.DELETE_TOPIC))
+                .thenAccept(__ -> 
pulsar().getBrokerService().deleteTopic(topicName.toString(), false))

Review Comment:
   thanks



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