-
Notifications
You must be signed in to change notification settings - Fork 15.1k
MINOR: Fix potential NPE #21846
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
MINOR: Fix potential NPE #21846
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -250,7 +250,10 @@ public Map<TopicIdPartition, NodeAcknowledgements> takeAcknowledgedRecords() { | |
| public int renew(Map<TopicIdPartition, Acknowledgements> acknowledgementsMap, Optional<Integer> acquisitionLockTimeoutMs) { | ||
| int recordsRenewed = 0; | ||
| for (Map.Entry<TopicIdPartition, Acknowledgements> entry : acknowledgementsMap.entrySet()) { | ||
| recordsRenewed += batches.get(entry.getKey()).renew(entry.getValue()); | ||
| ShareInFlightBatch<K, V> batch = batches.get(entry.getKey()); | ||
| if (batch != null) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch on the NPE. Only nit: can we add a brief note on renew that missing batches are intentionally skipped? |
||
| recordsRenewed += batch.renew(entry.getValue()); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1- Does that make sense to add such a test (as you mentioned you hitted in once during testing)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My suspicion is that I temporarily broke the code while working on another PR on trunk and it revealed that this piece of code was a bit less defensive than it should have been. I'll finish off the larger trunk PR later this week, and I will enhance this small 4.2 PR if necessary. @chia7712 @nileshkumar3 |
||
| } | ||
| acquisitionLockTimeoutMsRenewed = acquisitionLockTimeoutMs; | ||
| return recordsRenewed; | ||
|
|
||
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.
Good defensive check, but just out of curiosity, what causes this to end up being
null?