liangyepianzhou commented on code in PR #18307:
URL: https://github.com/apache/pulsar/pull/18307#discussion_r1013561593


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:
##########
@@ -218,38 +218,47 @@ protected CompletableFuture<Void> 
internalDeleteNamespaceAsync(boolean force) {
                          }))
                 .thenCompose(topics -> {
                     List<String> allTopics = topics.get(0);
+                    ArrayList<String> copyAllTopics = new ArrayList<>();
                     List<String> allPartitionedTopics = topics.get(1);
-                    if (!force) {
-                        boolean hasNonSystemTopic = false;
-                        for (String topic : allTopics) {
-                            if 
(!pulsar().getBrokerService().isSystemTopic(TopicName.get(topic))) {
-                                hasNonSystemTopic = true;
-                                break;
-                            }
+                    ArrayList<String> copyAllPartitionTopics = new 
ArrayList<>();
+                    boolean hasNonSystemTopic = false;
+                    List<String> allSystemTopics = new ArrayList<>();
+                    List<String> allPartitionedSystemTopics = new 
ArrayList<>();
+                    for (String topic : allTopics) {
+                        if 
(!pulsar().getBrokerService().isSystemTopic(TopicName.get(topic))) {
+                            hasNonSystemTopic = true;
+                            copyAllTopics.add(topic);
+                        } else {
+                            allSystemTopics.add(topic);
                         }
-                        if (!hasNonSystemTopic) {
-                            for (String topic : allPartitionedTopics) {
-                                if 
(!pulsar().getBrokerService().isSystemTopic(TopicName.get(topic))) {
-                                    hasNonSystemTopic = true;
-                                    break;
-                                }
-                            }
+                    }
+                    for (String topic : allPartitionedTopics) {
+                        if 
(!pulsar().getBrokerService().isSystemTopic(TopicName.get(topic))) {
+                            hasNonSystemTopic = true;
+                            copyAllPartitionTopics.add(topic);
+                        } else {
+                            allPartitionedSystemTopics.add(topic);
                         }
-
+                    }
+                    if (!force) {
                         if (hasNonSystemTopic) {
                             throw new RestException(Status.CONFLICT, "Cannot 
delete non empty namespace");
                         }
                     }
                     return 
namespaceResources().setPoliciesAsync(namespaceName, old -> {
                         old.deleted = true;
                         return  old;
-                    }).thenCompose(__ -> {
-                        return internalDeleteTopicsAsync(allTopics);
-                    }).thenCompose(__ -> {
-                        return 
internalDeletePartitionedTopicsAsync(allPartitionedTopics);
+                    }).thenCompose(ignore -> {
+                        return internalDeleteTopicsAsync(copyAllTopics);
+                    }).thenCompose(ignore -> {
+                        return 
internalDeletePartitionedTopicsAsync(copyAllPartitionTopics);
+                    }).thenCompose(ignore -> {
+                        return internalDeleteTopicsAsync(allSystemTopics);
+                    }).thenCompose(ignore__ -> {
+                        return 
internalDeletePartitionedTopicsAsync(allPartitionedSystemTopics);

Review Comment:
   In fact, deleting the namespace in TransactionTest is just like this, there 
are systemtopic[`__change_event`, `__transaction_buffer_snapshot`] and normal 
topic[`test`, `testDeleteNamespaceAfterUsedTransaction`] in the namespace.
   But you are right, we can add `assertTrue` to make it clear.



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