codelipenghui commented on a change in pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#discussion_r831280068



##########
File path: 
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
##########
@@ -1697,7 +1697,8 @@ public void asyncMarkDelete(final Position position, 
Map<String, Long> propertie
             try {
                 long ledgerEntries = 
ledger.getLedgerInfo(markDeletePosition.getLedgerId()).get().getEntries();
                 Long nextValidLedger = 
ledger.getNextValidLedger(ledger.getLastConfirmedEntry().getLedgerId());
-                shouldCursorMoveForward = (markDeletePosition.getEntryId() + 1 
>= ledgerEntries)
+                shouldCursorMoveForward = nextValidLedger != null
+                        && (markDeletePosition.getEntryId() + 1 >= 
ledgerEntries)
                         && (newPosition.getLedgerId() == nextValidLedger);

Review comment:
       ```suggestion
                   shouldCursorMoveForward = (markDeletePosition.getEntryId() + 
1 >= ledgerEntries)
                           && (nextValidLedger != null && 
newPosition.getLedgerId() == nextValidLedger);
   ```




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