Technoboy- commented on a change in pull request #14876:
URL: https://github.com/apache/pulsar/pull/14876#discussion_r837406875



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TransactionsBase.java
##########
@@ -519,57 +519,52 @@ protected void 
internalGetPendingAckInternalStats(AsyncResponse asyncResponse, b
                     topicFuture.whenComplete((optionalTopic, e) -> {
 
                         if (e != null) {
-                            asyncResponse.resume(new RestException(e));
+                            resumeAsyncResponseExceptionally(asyncResponse, e);
                             return;
                         }
                         if (!optionalTopic.isPresent()) {
-                            asyncResponse.resume(new 
RestException(TEMPORARY_REDIRECT,
-                                    "Topic is not owned by this broker!"));
+                            asyncResponse.resume(new RestException(NOT_FOUND, 
"Topic not found"));
                             return;
                         }
                         Topic topicObject = optionalTopic.get();
-                        if (topicObject instanceof PersistentTopic) {
-                            try {
-                                ManagedLedger managedLedger =
-                                        ((PersistentTopic) 
topicObject).getPendingAckManagedLedger(subName).get();
-                                TransactionPendingAckInternalStats stats =
-                                        new 
TransactionPendingAckInternalStats();
-                                TransactionLogStats pendingAckLogStats = new 
TransactionLogStats();
-                                pendingAckLogStats.managedLedgerName = 
managedLedger.getName();
-                                pendingAckLogStats.managedLedgerInternalStats =
-                                        
managedLedger.getManagedLedgerInternalStats(metadata).get();
-                                stats.pendingAckLogStats = pendingAckLogStats;
-                                asyncResponse.resume(stats);
-                            } catch (Exception exception) {
-                                if (exception instanceof ExecutionException) {
-                                    if (exception.getCause() instanceof 
ServiceUnitNotReadyException) {
-                                        asyncResponse.resume(new 
RestException(SERVICE_UNAVAILABLE,
-                                                exception.getCause()));
-                                        return;
-                                    } else if (exception.getCause() instanceof 
NotAllowedException) {
-                                        asyncResponse.resume(new 
RestException(METHOD_NOT_ALLOWED,
-                                                exception.getCause()));
-                                        return;
-                                    } else if (exception.getCause() instanceof 
SubscriptionNotFoundException) {
-                                        asyncResponse.resume(new 
RestException(NOT_FOUND, exception.getCause()));
-                                        return;
-                                    }
+                        try {
+                            ManagedLedger managedLedger =
+                                    ((PersistentTopic) 
topicObject).getPendingAckManagedLedger(subName).get();

Review comment:
       Make `internalGetPendingAckInternalStats` fully async.

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TransactionsBase.java
##########
@@ -519,57 +519,52 @@ protected void 
internalGetPendingAckInternalStats(AsyncResponse asyncResponse, b
                     topicFuture.whenComplete((optionalTopic, e) -> {
 
                         if (e != null) {
-                            asyncResponse.resume(new RestException(e));
+                            resumeAsyncResponseExceptionally(asyncResponse, e);
                             return;
                         }
                         if (!optionalTopic.isPresent()) {
-                            asyncResponse.resume(new 
RestException(TEMPORARY_REDIRECT,
-                                    "Topic is not owned by this broker!"));
+                            asyncResponse.resume(new RestException(NOT_FOUND, 
"Topic not found"));
                             return;
                         }
                         Topic topicObject = optionalTopic.get();
-                        if (topicObject instanceof PersistentTopic) {
-                            try {
-                                ManagedLedger managedLedger =
-                                        ((PersistentTopic) 
topicObject).getPendingAckManagedLedger(subName).get();
-                                TransactionPendingAckInternalStats stats =
-                                        new 
TransactionPendingAckInternalStats();
-                                TransactionLogStats pendingAckLogStats = new 
TransactionLogStats();
-                                pendingAckLogStats.managedLedgerName = 
managedLedger.getName();
-                                pendingAckLogStats.managedLedgerInternalStats =
-                                        
managedLedger.getManagedLedgerInternalStats(metadata).get();
-                                stats.pendingAckLogStats = pendingAckLogStats;
-                                asyncResponse.resume(stats);
-                            } catch (Exception exception) {
-                                if (exception instanceof ExecutionException) {
-                                    if (exception.getCause() instanceof 
ServiceUnitNotReadyException) {
-                                        asyncResponse.resume(new 
RestException(SERVICE_UNAVAILABLE,
-                                                exception.getCause()));
-                                        return;
-                                    } else if (exception.getCause() instanceof 
NotAllowedException) {
-                                        asyncResponse.resume(new 
RestException(METHOD_NOT_ALLOWED,
-                                                exception.getCause()));
-                                        return;
-                                    } else if (exception.getCause() instanceof 
SubscriptionNotFoundException) {
-                                        asyncResponse.resume(new 
RestException(NOT_FOUND, exception.getCause()));
-                                        return;
-                                    }
+                        try {
+                            ManagedLedger managedLedger =
+                                    ((PersistentTopic) 
topicObject).getPendingAckManagedLedger(subName).get();

Review comment:
       @eolivelli 




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