Skip to content

MINOR: Fix potential NPE#21846

Open
AndrewJSchofield wants to merge 1 commit intoapache:4.2from
AndrewJSchofield:MINOR-npe-4.2
Open

MINOR: Fix potential NPE#21846
AndrewJSchofield wants to merge 1 commit intoapache:4.2from
AndrewJSchofield:MINOR-npe-4.2

Conversation

@AndrewJSchofield
Copy link
Member

@AndrewJSchofield AndrewJSchofield commented Mar 21, 2026

Fixes a potential NPE in ShareFetch. I have hit it once during
testing, but only once. Fix in progress on trunk and will include in
4.3.0. This is worth putting into 4.2.1.

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

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());
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants