casuallc opened a new issue #11796:
URL: https://github.com/apache/pulsar/issues/11796
**function call chain:**
**ManagedCursorImpl**
```java
@Override
public void asyncReadEntries(int numberOfEntriesToRead, long maxSizeBytes,
ReadEntriesCallback callback,
Object ctx, PositionImpl maxPosition) {
checkArgument(numberOfEntriesToRead > 0);
if (isClosed()) {
callback.readEntriesFailed(new ManagedLedgerException
.CursorAlreadyClosedException("Cursor was already closed"),
ctx);
return;
}
int numOfEntriesToRead = applyMaxSizeCap(numberOfEntriesToRead,
maxSizeBytes);
PENDING_READ_OPS_UPDATER.incrementAndGet(this);
OpReadEntry op = OpReadEntry.create(this, readPosition,
numOfEntriesToRead, callback, ctx, maxPosition);
ledger.asyncReadEntries(op);
}
```
**OpReadEntry**
```java
public static OpReadEntry create(ManagedCursorImpl cursor, PositionImpl
readPositionRef, int count,
ReadEntriesCallback callback, Object ctx, PositionImpl
maxPosition) {
OpReadEntry op = RECYCLER.get();
op.readPosition =
cursor.ledger.startReadOperationOnLedger(readPositionRef, op);
op.cursor = cursor;
op.count = count;
op.callback = callback;
op.entries = Lists.newArrayList();
if (maxPosition == null) {
maxPosition = PositionImpl.latest;
}
op.maxPosition = maxPosition;
op.ctx = ctx;
op.nextReadPosition = PositionImpl.get(op.readPosition);
return op;
}
```
**ManagedLedgerImpl**
````java
PositionImpl startReadOperationOnLedger(PositionImpl position, OpReadEntry
opReadEntry) {
Long ledgerId = ledgers.ceilingKey(position.getLedgerId());
if (null == ledgerId) {
opReadEntry.readEntriesFailed(new
ManagedLedgerException.NoMoreEntriesToReadException("The ceilingKey(K key)
method is used to return the " +
"least key greater than or equal to the given key, or null
if there is no such key"), null);
}
```
if (ledgerId != position.getLedgerId()) {
// The ledger pointed by this position does not exist anymore. It was
deleted because it was empty. We need
// to skip on the next available ledger
position = new PositionImpl(ledgerId, 0);
}
return position;
```
}
````
**OpReadEntry**
```java
@Override
public void readEntriesFailed(ManagedLedgerException exception, Object ctx) {
cursor.readOperationCompleted();
// ...
}
```
**description**
if read ledger not in ledgers, there is a exception.
but OpReadEntry instance is not be initialized, variable cursor is null.
function readEntriesFailed will throw NPE, and OpReadEntry is not recycle.
--
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]