-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[ISSUE 11796] throw NPE when readEntry #11813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| OpReadEntry op = OpReadEntry.create(this, readPosition, numberOfEntriesToRead, callback, | ||
| ctx, maxPosition); | ||
| if (op.readPosition == null) { | ||
| return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we need to call the method callback.readEntriesFailed to make sure the caller gets a result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
op is not recycle if op.readPosition == null
By the way, could you add some unit test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.