[ISSUE 11796] throw NPE when readEntry#11813
Conversation
| OpReadEntry op = OpReadEntry.create(this, readPosition, numberOfEntriesToRead, callback, | ||
| ctx, maxPosition); | ||
| if (op.readPosition == null) { | ||
| return; |
There was a problem hiding this comment.
Maybe we need to call the method callback.readEntriesFailed to make sure the caller gets a result.
There was a problem hiding this comment.
Do not need call the method here, if OpReadEntry init failed, must ensure OpReadEntry->readEntriesFailed will be called, callback.readEntriesFailed will be called then.
| PENDING_READ_OPS_UPDATER.incrementAndGet(this); | ||
| OpReadEntry op = OpReadEntry.create(this, readPosition, numOfEntriesToRead, callback, ctx, maxPosition); | ||
| ledger.asyncReadEntries(op); | ||
| if (op.readPosition != null) { |
There was a problem hiding this comment.
op is not recycle if op.readPosition == null
By the way, could you add some unit test?
There was a problem hiding this comment.
op recycled when the method OpReadEntry->readEntriesFailed called.
At present, op init failed only if op.readPosition = cursor.ledger.startReadOperationOnLedger(readPositionRef, op); called.
I do not know how to test this case ...
|
good work @casuallc . The changes in this PR seem to be necessary for handling the failure case that is highlighted. btw. There seems to be a similar change #11292 in progress, but that is taking a different approach for solving a similar issue. I'd prefer the approach used in this PR over the changes in 11292 since the solution in this PR is very simple. |
@lhotari That's why I try to init |
@Jason918 Yes, you are right. I should check op but not op.readPosition. |
|
@lhotari code
Am i right ? |
|
Closing and re-opening this PR to trigger a fresh build. |
|
@casuallc It looks like your branch for this PR is gone and this PR cannot be re-opened. I closed it with the intention to trigger a rebuild. Rebuilding on CI was disabled and now I can see that the reason was that the original PR branch has been deleted. @casuallc Would you mind creating a new PR with the same changes? |
|
@nicoloboschi @eolivelli The changes in this PR would be useful for fixing a common NPE issue #11796. |
|
Fixes #11796
[ISSUE 11796] throw NPE when readEntry
No need doc.