lordcheng10 commented on code in PR #17753:
URL: https://github.com/apache/pulsar/pull/17753#discussion_r981163883


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java:
##########
@@ -3445,6 +3445,32 @@ public PositionImpl getNextValidPosition(final 
PositionImpl position) {
         return next;
     }
 
+    public PositionImpl getValidPositionAfterSkippedEntries(final PositionImpl 
position, int skippedEntryNum) {
+        PositionImpl skippedPosition;
+        try {
+            skippedPosition = getValidPositionInternal(position, 
skippedEntryNum);
+        } catch (NullPointerException e) {
+            skippedPosition = lastConfirmedEntry.getNext();
+            if (log.isDebugEnabled()) {
+                log.debug("[{}] Can't find valid position : {}, fall back to 
the next position of the last "
+                        + "position : {}.", position, name, skippedPosition, 
e);
+            }
+        }
+        return skippedPosition;
+    }
+
+    public PositionImpl getValidPositionInternal(final PositionImpl position, 
int skippedEntryNum) {
+        PositionImpl toPosition = 
position.getPositionAfterEntries(skippedEntryNum);
+        while (!isValidPosition(toPosition)) {
+            Long nextLedgerId = ledgers.ceilingKey(toPosition.getLedgerId() + 
1);
+            if (nextLedgerId == null) {
+                throw new NullPointerException();

Review Comment:
   OK, I will fix



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