oneby-wang commented on code in PR #25110:
URL: https://github.com/apache/pulsar/pull/25110#discussion_r2672362201
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java:
##########
@@ -1243,14 +1243,17 @@ public boolean hasMoreEntries() {
@Override
public long getNumberOfEntries() {
- if (readPosition.compareTo(ledger.getLastPosition().getNext()) > 0) {
+ Position readPos = readPosition;
+ Position lastPosition = ledger.getLastPosition();
+ Position nextPosition = lastPosition.getNext();
Review Comment:
By default positions is created by `PositionFactory.create()`, which return
an instance of `ImmutablePositionImpl`. If somewhere creates a position not
using `PositionFactory.create()`, I think we should modify it.
I think this can make sure that we could catch a snapshot view if we
snapshot positions into local varaiables.
I ran a lot of tests locally, and it appears that the error of
`java.lang.IllegalArgumentException: Invalid range: [104:0..103:1)` no longer
occurs.
--
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]