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/07/26 05:26:17 UTC

[GitHub] [pulsar] mattisonchao commented on a diff in pull request #16662: fix stats-internal with option -m cause active ledger recover then close

mattisonchao commented on code in PR #16662:
URL: https://github.com/apache/pulsar/pull/16662#discussion_r929536271


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java:
##########
@@ -1794,7 +1794,12 @@ void asyncReadEntries(OpReadEntry opReadEntry) {
     }
 
     public CompletableFuture<String> getLedgerMetadata(long ledgerId) {
-        return getLedgerHandle(ledgerId).thenApply(rh -> rh.getLedgerMetadata().toSafeString());
+        LedgerHandle currentLedger = this.currentLedger;
+        if (currentLedger != null && ledgerId == currentLedger.getId()) {
+            return CompletableFuture.completedFuture(currentLedger.getLedgerMetadata().toSafeString());

Review Comment:
   I'm not sure if `currentLedger.getLedgerMetadata().toSafeString()` will throw exception to break the the encapsulation of the method. Because we return the `CompletableFuture` but have a risk throw exception out of the `CompletableFuture` chain.
   
   Could you help to confirm it?



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