merlimat commented on code in PR #25618:
URL: https://github.com/apache/pulsar/pull/25618#discussion_r3162396204


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/ScalableTopics.java:
##########
@@ -268,14 +273,15 @@ public void getStats(
         validateNamespaceName(tenant, namespace);
         TopicName tn = TopicName.get(TopicDomain.topic.value(), namespaceName, 
encodedTopic);
 
-        var scalableTopicService = 
pulsar().getBrokerService().getScalableTopicService();
-        if (scalableTopicService == null) {
-            asyncResponse.resume(new 
RestException(Response.Status.SERVICE_UNAVAILABLE,
-                    "Scalable topic service not available"));
-            return;
-        }
-
-        scalableTopicService.getStats(tn)
+        validateTopicOperationAsync(tn, TopicOperation.GET_STATS)
+                .thenCompose(__ -> {
+                    var scalableTopicService = 
pulsar().getBrokerService().getScalableTopicService();
+                    if (scalableTopicService == null) {
+                        throw new 
RestException(Response.Status.SERVICE_UNAVAILABLE,
+                                "Scalable topic service not available");
+                    }
+                    return scalableTopicService.getStats(tn);
+                })

Review Comment:
   Would it be worth to encapsulate the redirect in a helper method?



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