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



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Transactions.java
##########
@@ -222,7 +228,24 @@ public void getPendingAckInternalStats(@Suspended final 
AsyncResponse asyncRespo
                                            @PathParam("topic") @Encoded String 
encodedTopic,
                                            @PathParam("subName") String 
subName,
                                            @QueryParam("metadata") 
@DefaultValue("false") boolean metadata) {
-        internalGetPendingAckInternalStats(asyncResponse, authoritative,
-                TopicName.get(TopicDomain.persistent.value(), tenant, 
namespace, encodedTopic), subName, metadata);
+
+        internalGetPendingAckInternalStats(authoritative,
+                    TopicName.get(TopicDomain.persistent.value(), tenant, 
namespace, encodedTopic), subName, metadata)

Review comment:
       I think we need to catch ``TopicName.get(TopicDomain.persistent.value(), 
tenant, namespace, encodedTopic)`` to avoid ``IllegalArgumentsException`` 
exception.

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Transactions.java
##########
@@ -222,7 +228,24 @@ public void getPendingAckInternalStats(@Suspended final 
AsyncResponse asyncRespo
                                            @PathParam("topic") @Encoded String 
encodedTopic,
                                            @PathParam("subName") String 
subName,
                                            @QueryParam("metadata") 
@DefaultValue("false") boolean metadata) {
-        internalGetPendingAckInternalStats(asyncResponse, authoritative,
-                TopicName.get(TopicDomain.persistent.value(), tenant, 
namespace, encodedTopic), subName, metadata);
+
+        internalGetPendingAckInternalStats(authoritative,
+                    TopicName.get(TopicDomain.persistent.value(), tenant, 
namespace, encodedTopic), subName, metadata)
+                .thenAccept(stats -> asyncResponse.resume(stats))

Review comment:
       should we add success log here?

##########
File path: 
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/v3/AdminApiTransactionTest.java
##########
@@ -373,6 +375,23 @@ public void testGetPendingAckInternalStats() throws 
Exception {
         TransactionImpl transaction = (TransactionImpl) getTransaction();
         final String topic = 
"persistent://public/default/testGetPendingAckInternalStats";
         final String subName = "test";
+        try {
+            admin.transactions()
+                    .getPendingAckInternalStatsAsync(topic, subName, 
true).get();

Review comment:
       Maybe we need to add ``Assert.fail()`` here.

##########
File path: 
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/v3/AdminApiTransactionTest.java
##########
@@ -373,6 +375,23 @@ public void testGetPendingAckInternalStats() throws 
Exception {
         TransactionImpl transaction = (TransactionImpl) getTransaction();
         final String topic = 
"persistent://public/default/testGetPendingAckInternalStats";
         final String subName = "test";
+        try {
+            admin.transactions()
+                    .getPendingAckInternalStatsAsync(topic, subName, 
true).get();
+        } catch (ExecutionException ex) {
+            assertTrue(ex.getCause() instanceof 
PulsarAdminException.NotFoundException);
+            PulsarAdminException.NotFoundException cause = 
(PulsarAdminException.NotFoundException)ex.getCause();
+            assertEquals(cause.getMessage(), "Topic not found");
+        }
+        try {
+            pulsar.getBrokerService().getTopic(topic, false);
+            admin.transactions()
+                    .getPendingAckInternalStatsAsync(topic, subName, 
true).get();

Review comment:
       Maybe we need to add ``Assert.fail()`` here.

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Transactions.java
##########
@@ -222,7 +228,24 @@ public void getPendingAckInternalStats(@Suspended final 
AsyncResponse asyncRespo
                                            @PathParam("topic") @Encoded String 
encodedTopic,
                                            @PathParam("subName") String 
subName,
                                            @QueryParam("metadata") 
@DefaultValue("false") boolean metadata) {
-        internalGetPendingAckInternalStats(asyncResponse, authoritative,
-                TopicName.get(TopicDomain.persistent.value(), tenant, 
namespace, encodedTopic), subName, metadata);
+
+        internalGetPendingAckInternalStats(authoritative,
+                    TopicName.get(TopicDomain.persistent.value(), tenant, 
namespace, encodedTopic), subName, metadata)
+                .thenAccept(stats -> asyncResponse.resume(stats))
+                .exceptionally(ex -> {
+                    Throwable cause = FutureUtil.unwrapCompletionException(ex);

Review comment:
       should we add exception log 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-unsubscr...@pulsar.apache.org

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


Reply via email to