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



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java
##########
@@ -116,13 +116,28 @@ public void getList(
             @ApiResponse(code = 404, message = "tenant/namespace/topic doesn't 
exit"),
             @ApiResponse(code = 412, message = "Namespace name is not valid"),
             @ApiResponse(code = 500, message = "Internal server error")})
-    public List<String> getPartitionedTopicList(
+    public void getPartitionedTopicList(
+            @Suspended AsyncResponse asyncResponse,
             @ApiParam(value = "Specify the tenant", required = true)
             @PathParam("tenant") String tenant,
             @ApiParam(value = "Specify the namespace", required = true)
             @PathParam("namespace") String namespace) {
-        validateNamespaceName(tenant, namespace);
-        return internalGetPartitionedTopicList();
+        try {
+            validateNamespaceName(tenant, namespace);
+        } catch (Exception ex) {
+            // validate namespace fail.
+            resumeAsyncResponseExceptionally(asyncResponse, ex);
+            return;
+        }
+        internalGetPartitionedTopicList()
+            .thenAccept(partitionedTopicList -> {
+                log.info("[{}] Successfully to get partitioned topic list 
{}/{}", clientAppId(), tenant, namespace);
+                asyncResponse.resume(partitionedTopicList);
+            }).exceptionally(ex -> {
+                log.error("[{}] Failed to get partitioned topic list {}", 
clientAppId(), namespaceName, ex);
+                resumeAsyncResponseExceptionally(asyncResponse, ex);

Review comment:
       We don't need to "getCause" here. Because 
``resumeAsyncResponseExceptionally`` already does it internally.

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/PersistentTopics.java
##########
@@ -90,10 +89,27 @@ public void getList(@Suspended final AsyncResponse 
asyncResponse, @PathParam("pr
     @ApiResponses(value = {
             @ApiResponse(code = 403, message = "Don't have admin or operate 
permission on the namespace"),
             @ApiResponse(code = 404, message = "Namespace doesn't exist")})
-    public List<String> getPartitionedTopicList(@PathParam("property") String 
property,
-            @PathParam("cluster") String cluster, @PathParam("namespace") 
String namespace) {
-        validateNamespaceName(property, cluster, namespace);
-        return internalGetPartitionedTopicList();
+    public void getPartitionedTopicList(@Suspended AsyncResponse asyncResponse,
+                                        @PathParam("property") String property,
+                                        @PathParam("cluster") String cluster,
+                                        @PathParam("namespace") String 
namespace) {
+        try {
+            validateNamespaceName(property, cluster, namespace);
+        } catch (Exception ex) {
+            // validate namespace fail.
+            resumeAsyncResponseExceptionally(asyncResponse, ex);
+            return;
+        }
+        internalGetPartitionedTopicList()
+            .thenAccept(partitionedTopicList -> {
+                log.info("[{}] Successfully to get partitioned topic list 
{}/{}",
+                        clientAppId(), cluster, namespace);
+                asyncResponse.resume(partitionedTopicList);
+            }).exceptionally(ex -> {
+                log.error("[{}] Failed to get partitioned topic list {}", 
clientAppId(), namespaceName, ex);
+                resumeAsyncResponseExceptionally(asyncResponse, ex);

Review comment:
       We don't need to "getCause" here. Because 
``resumeAsyncResponseExceptionally`` already does it internally.




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