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



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -1199,103 +1199,110 @@ protected PersistentTopicInternalStats 
internalGetInternalStats(boolean authorit
     }
 
     protected void internalGetManagedLedgerInfo(AsyncResponse asyncResponse, 
boolean authoritative) {
+        CompletableFuture<Void> future;
         if (topicName.isGlobal()) {
-            try {
-                validateGlobalNamespaceOwnership(namespaceName);
-            } catch (Exception e) {
-                log.error("[{}] Failed to get managed info for {}", 
clientAppId(), topicName, e);
-                resumeAsyncResponseExceptionally(asyncResponse, e);
-                return;
-            }
-        }
-
-        // If the topic name is a partition name, no need to get partition 
topic metadata again
-        if (topicName.isPartitioned()) {
-            internalGetManagedLedgerInfoForNonPartitionedTopic(asyncResponse);
+            future = validateGlobalNamespaceOwnershipAsync(namespaceName);
         } else {
-            getPartitionedTopicMetadataAsync(topicName,
-                    authoritative, false).thenAccept(partitionMetadata -> {
-                if (partitionMetadata.partitions > 0) {
-                    final List<CompletableFuture<String>> futures = 
Lists.newArrayList();
-
-                    PartitionedManagedLedgerInfo partitionedManagedLedgerInfo 
= new PartitionedManagedLedgerInfo();
-
-                    for (int i = 0; i < partitionMetadata.partitions; i++) {
-                        TopicName topicNamePartition = 
topicName.getPartition(i);
-                        try {
-                            futures.add(pulsar().getAdminClient().topics()
-                                    .getInternalInfoAsync(
-                                            
topicNamePartition.toString()).whenComplete((response, throwable) -> {
-                                        if (throwable != null) {
-                                            log.error("[{}] Failed to get 
managed info for {}",
-                                                    clientAppId(), 
topicNamePartition, throwable);
-                                            asyncResponse.resume(new 
RestException(throwable));
-                                        }
-                                        try {
-                                            
partitionedManagedLedgerInfo.partitions.put(topicNamePartition.toString(),
-                                                    
jsonMapper().readValue(response,
-                                                            
ManagedLedgerInfo.class));
-                                        } catch (JsonProcessingException ex) {
-                                            log.error("[{}] Failed to parse 
ManagedLedgerInfo for {} from [{}]",
-                                                    clientAppId(),
-                                                    topicNamePartition, 
response, ex);
-                                        }
-                                    }));
-                        } catch (Exception e) {
-                            log.error("[{}] Failed to get managed info for 
{}", clientAppId(), topicNamePartition, e);
-                            throw new RestException(e);
+            future = CompletableFuture.completedFuture(null);
+        }
+        future.thenAccept(__ -> {
+            // If the topic name is a partition name, no need to get partition 
topic metadata again
+            if (topicName.isPartitioned()) {
+                
internalGetManagedLedgerInfoForNonPartitionedTopic(asyncResponse);
+            } else {
+                getPartitionedTopicMetadataAsync(topicName, authoritative, 
false)
+                        .thenAccept(partitionMetadata -> {
+                    if (partitionMetadata.partitions > 0) {
+                        final List<CompletableFuture<String>> futures =
+                                
Lists.newArrayListWithCapacity(partitionMetadata.partitions);
+                        PartitionedManagedLedgerInfo 
partitionedManagedLedgerInfo = new PartitionedManagedLedgerInfo();
+                        for (int i = 0; i < partitionMetadata.partitions; i++) 
{
+                            TopicName topicNamePartition = 
topicName.getPartition(i);
+                            try {
+                                futures.add(pulsar().getAdminClient().topics()
+                                        
.getInternalInfoAsync(topicNamePartition.toString())
+                                        .whenComplete((response, throwable) -> 
{
+                                            if (throwable != null) {
+                                                log.error("[{}] Failed to get 
managed info for {}",
+                                                        clientAppId(), 
topicNamePartition, throwable);
+                                                asyncResponse.resume(new 
RestException(throwable));
+                                            }
+                                            try {
+                                                
partitionedManagedLedgerInfo.partitions
+                                                        
.put(topicNamePartition.toString(), jsonMapper()
+                                                                
.readValue(response, ManagedLedgerInfo.class));
+                                            } catch (JsonProcessingException 
ex) {
+                                                log.error("[{}] Failed to 
parse ManagedLedgerInfo for {} from [{}]",
+                                                        clientAppId(), 
topicNamePartition, response, ex);
+                                            }
+                                        })
+                                );
+                            } catch (Exception e) {

Review comment:
       fixed. PTAL :-)




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