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/04/26 12:39:21 UTC

[GitHub] [pulsar] Technoboy- commented on a diff in pull request #14188: Make TopicLookupBase#internalLookupTopicAsync pure async

Technoboy- commented on code in PR #14188:
URL: https://github.com/apache/pulsar/pull/14188#discussion_r858662685


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v1/TopicLookup.java:
##########
@@ -57,18 +59,27 @@ public class TopicLookup extends TopicLookupBase {
     @Produces(MediaType.APPLICATION_JSON)
     @ApiResponses(value = { @ApiResponse(code = 307,
             message = "Current broker doesn't serve the namespace of this topic") })
-    public void lookupTopicAsync(@PathParam("topic-domain") String topicDomain, @PathParam("property") String property,
+    public void lookupTopicAsync(
+            @Suspended AsyncResponse asyncResponse,
+            @PathParam("topic-domain") String topicDomain, @PathParam("property") String property,
             @PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
             @PathParam("topic") @Encoded String encodedTopic,
             @QueryParam("authoritative") @DefaultValue("false") boolean authoritative,
-            @Suspended AsyncResponse asyncResponse,
             @QueryParam("listenerName") String listenerName,
             @HeaderParam(LISTENERNAME_HEADER) String listenerNameHeader) {
         TopicName topicName = getTopicName(topicDomain, property, cluster, namespace, encodedTopic);
         if (StringUtils.isEmpty(listenerName) && StringUtils.isNotEmpty(listenerNameHeader)) {
             listenerName = listenerNameHeader;
         }
-        internalLookupTopicAsync(topicName, authoritative, asyncResponse, listenerName);
+        internalLookupTopicAsync(topicName, authoritative, listenerName)
+                .thenAccept(lookupData -> asyncResponse.resume(lookupData))
+                .exceptionally(e -> {
+                    if (log.isDebugEnabled()) {
+                        log.debug("Failed to check exist for topic {} when lookup", topicName, e.getCause());
+                    }
+                    completeLookupResponseExceptionally(asyncResponse, e.getCause());

Review Comment:
   fixed.



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v2/TopicLookup.java:
##########
@@ -45,17 +47,26 @@ public class TopicLookup extends TopicLookupBase {
     @Produces(MediaType.APPLICATION_JSON)
     @ApiResponses(value = { @ApiResponse(code = 307,
             message = "Current broker doesn't serve the namespace of this topic") })
-    public void lookupTopicAsync(@PathParam("topic-domain") String topicDomain, @PathParam("tenant") String tenant,
+    public void lookupTopicAsync(
+            @Suspended AsyncResponse asyncResponse,
+            @PathParam("topic-domain") String topicDomain, @PathParam("tenant") String tenant,
             @PathParam("namespace") String namespace, @PathParam("topic") @Encoded String encodedTopic,
             @QueryParam("authoritative") @DefaultValue("false") boolean authoritative,
-            @Suspended AsyncResponse asyncResponse,
             @QueryParam("listenerName") String listenerName,
             @HeaderParam(LISTENERNAME_HEADER) String listenerNameHeader) {
         TopicName topicName = getTopicName(topicDomain, tenant, namespace, encodedTopic);
         if (StringUtils.isEmpty(listenerName) && StringUtils.isNotEmpty(listenerNameHeader)) {
             listenerName = listenerNameHeader;
         }
-        internalLookupTopicAsync(topicName, authoritative, asyncResponse, listenerName);
+        internalLookupTopicAsync(topicName, authoritative, listenerName)
+                .thenAccept(lookupData -> asyncResponse.resume(lookupData))
+                .exceptionally(e -> {
+                    if (log.isDebugEnabled()) {
+                        log.debug("Failed to check exist for topic {} when lookup", topicName, e.getCause());
+                    }
+                    completeLookupResponseExceptionally(asyncResponse, e.getCause());

Review Comment:
   fixed



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