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/03/21 16:05:48 UTC

[GitHub] [pulsar] codelipenghui commented on a change in pull request #13975: [managed-ledger] Fix when nextValidLedger is null caused NPE

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: commits-unsubscribe@pulsar.apache.org

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