You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/01/21 12:45:23 UTC

[GitHub] [pulsar] codelipenghui commented on a change in pull request #13805: [Broker] Fix call sync method in async rest api for ``internalDeletePartitionedTopic``

codelipenghui commented on a change in pull request #13805:
URL: https://github.com/apache/pulsar/pull/13805#discussion_r789626509



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -560,23 +560,12 @@ protected PartitionedTopicMetadata internalGetPartitionedMetadata(boolean author
 
     protected void internalDeletePartitionedTopic(AsyncResponse asyncResponse, boolean authoritative,
                                                   boolean force, boolean deleteSchema) {
-        try {
-            validateNamespaceOperation(topicName.getNamespaceObject(), NamespaceOperation.DELETE_TOPIC);
-            validateTopicOwnership(topicName, authoritative);
-        } catch (WebApplicationException wae) {
-            if (log.isDebugEnabled()) {
-                log.debug("[{}] Failed to delete partitioned topic {}, redirecting to other brokers.",
-                        clientAppId(), topicName, wae);
-            }
-            resumeAsyncResponseExceptionally(asyncResponse, wae);
-            return;
-        } catch (Exception e) {
-            log.error("[{}] Failed to delete partitioned topic {}", clientAppId(), topicName, e);
-            resumeAsyncResponseExceptionally(asyncResponse, e);
-            return;
-        }
+        CompletableFuture<PartitionedTopicMetadata> partitionedTopicMetadataCompletableFuture =
+                validateNamespaceOperationAsync(topicName.getNamespaceObject(), NamespaceOperation.DELETE_TOPIC)
+                .thenAccept(__ -> validateTopicOwnershipAsync(topicName, authoritative))
+                .thenCompose(__ -> pulsar().getBrokerService().fetchPartitionedTopicMetadataAsync(topicName));
         final CompletableFuture<Void> future = new CompletableFuture<>();

Review comment:
       We can remove this line?

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -560,23 +560,12 @@ protected PartitionedTopicMetadata internalGetPartitionedMetadata(boolean author
 
     protected void internalDeletePartitionedTopic(AsyncResponse asyncResponse, boolean authoritative,
                                                   boolean force, boolean deleteSchema) {
-        try {
-            validateNamespaceOperation(topicName.getNamespaceObject(), NamespaceOperation.DELETE_TOPIC);
-            validateTopicOwnership(topicName, authoritative);
-        } catch (WebApplicationException wae) {
-            if (log.isDebugEnabled()) {
-                log.debug("[{}] Failed to delete partitioned topic {}, redirecting to other brokers.",
-                        clientAppId(), topicName, wae);
-            }
-            resumeAsyncResponseExceptionally(asyncResponse, wae);
-            return;
-        } catch (Exception e) {
-            log.error("[{}] Failed to delete partitioned topic {}", clientAppId(), topicName, e);
-            resumeAsyncResponseExceptionally(asyncResponse, e);
-            return;
-        }
+        CompletableFuture<PartitionedTopicMetadata> partitionedTopicMetadataCompletableFuture =
+                validateNamespaceOperationAsync(topicName.getNamespaceObject(), NamespaceOperation.DELETE_TOPIC)
+                .thenAccept(__ -> validateTopicOwnershipAsync(topicName, authoritative))

Review comment:
       ```suggestion
                   .thenCompose(__ -> validateTopicOwnershipAsync(topicName, authoritative))
   ```

##########
File path: pulsar-common/src/main/java/org/apache/pulsar/common/util/FutureUtil.java
##########
@@ -174,6 +174,16 @@ public synchronized Throwable fillInStackTrace() {
         }
     }
 
+    public static Throwable getOriginalException(Throwable ex) {

Review comment:
       ```suggestion
       public static Throwable unwrapException(Throwable ex) {
   ```

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
##########
@@ -867,22 +867,42 @@ public void validateTenantOperation(String tenant, TenantOperation operation) {
     }
 
     public void validateNamespaceOperation(NamespaceName namespaceName, NamespaceOperation operation) {
+        try {
+            validateNamespaceOperationAsync(namespaceName, operation).get();

Review comment:
       Do we need a timeout here?




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org