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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to