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/03/29 09:56:46 UTC

[GitHub] [pulsar] Technoboy- commented on a change in pull request #14876: [fix][broker] Fix getPendingAckInternalStats redirect issue.

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



##########
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:
       Ok. I decided to change it to async, but a little from the original idea.
   Anyway, we should avoid using it like this. 
   I will update later.




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