BewareMyPower commented on code in PR #24089:
URL: https://github.com/apache/pulsar/pull/24089#discussion_r2000912435


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java:
##########
@@ -3826,9 +3826,19 @@ static long estimateEntryCountBySize(long bytesSize, 
Position readPosition, Mana
         long result = 0;
         long remainingBytesSize = bytesSize;
 
+        Position previousPosToRead = null;
         while (remainingBytesSize > 0) {
-            // Last ledger.
-            if (posToRead.getLedgerId() == ml.getCurrentLedger().getId()) {

Review Comment:
   Yeah it's right that the `currentLedger` could only be null when it's a 
readonly cursor. Hence there should be no race condition. But the pre-condition 
is **implicit**. Generally, adding null validation usually means the field is 
nullable without extra explanation.
   
   ```
               // Last ledger. This is null in ReadOnlyManagedLedgerImpl
   ```
   
   And this PR already contains the comment above. 



-- 
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-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to