Skip to content
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

[fix][client] Fix NPE when acknowledging multiple messages #19874

Merged

Conversation

BewareMyPower
Copy link
Contributor

@BewareMyPower BewareMyPower commented Mar 21, 2023

Motivation

For a multi-topics consumer, when it acknowledges a single message, it will first find the owner topic from its message ID. If the owner topic is not subscribed by the consumer, NotConnectedException will be thrown.

However, when it acknowledges multiple messages, if any of them is the message whose owner topic is not subscribed by the consumer, NPE will happen instead.

Modifications

When acknowledging multiple messages, if there is any message ID whose owner topic is not subscribed, fail the whole acknowledgment. testAckMessageInAnotherTopic is added to cover this case.

TODO

There are many other places that do not check if consumers.get returns null, like doReconsumeLater, negativeAcknowledge, etc. This patch does not cover them.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: BewareMyPower#22

### Motivation

For a multi-topics consumer, when it acknowledges a single message, it
will first find the owner topic from its message ID. If the owner topic
is not subscribed by the consumer, `NotConnectedException` will be
thrown.

However, when it acknowledges multiple messages, if any of them is the
message whose owner topic is not subscribed by the consumer, NPE will
happen instead.

### Modifications

When acknowledging multiple messages, ignore the message IDs whose owner
topic is not subscribed. `testAckMessageInAnotherTopic` is added to
cover this case.

### TODO

There are many other places that do not check if `consumers.get` returns
`null`, like `doReconsumeLater`, `negativeAcknowledge`, etc. This patch
does not cover them.
@github-actions
Copy link

@BewareMyPower Please add the following content to your PR description and select a checkbox:

- [ ] `doc` <!-- Your PR contains doc changes -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->

@BewareMyPower BewareMyPower added the type/bug The PR fixed a bug or issue reported a bug label Mar 21, 2023
@BewareMyPower BewareMyPower self-assigned this Mar 21, 2023
@github-actions github-actions bot added doc-not-needed Your PR changes do not impact docs and removed doc-label-missing labels Mar 21, 2023
@BewareMyPower
Copy link
Contributor Author

I decide to ignore these invalid message IDs because in real world, it usually happens when these messages are not received by the consumer or the topic of them has been deleted and the consumer subscribes topic by a regex.

Copy link
Member

@RobertIndie RobertIndie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@315157973 315157973 closed this Mar 24, 2023
@315157973 315157973 reopened this Mar 24, 2023
@Technoboy- Technoboy- added this to the 3.0.0 milestone Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-picked/branch-2.11 doc-not-needed Your PR changes do not impact docs ready-to-test release/2.11.2 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants