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

[improve][broker] Refactor a private method to eliminate an unnecessary parameter #23904

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

guan46
Copy link
Contributor

@guan46 guan46 commented Jan 28, 2025

Motivation

  • The canDispatchEntry method uses MutableBoolean as an argument, and then changes its value internally, but this variable is not necessary

Modifications

  • Optimize code for readability

Documentation

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

Matching PR in forked repository

PR in forked repository: guan46#1

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jan 28, 2025
if (permits.intValue() > 0) {
boolean canDispatchEntry = canDispatchEntry(consumer, entry, readType, stickyKeyHash);
if (!canDispatchEntry) {
blockedByHash.setTrue();
Copy link
Member

Choose a reason for hiding this comment

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

There needs to be a null check here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

please take a look again @lhotari

@lhotari lhotari changed the title [improve][broker]Variable modified in read method [improve][broker] Refactor a private method to eliminate an unnecessary parameter Jan 28, 2025
Comment on lines +443 to +452
boolean canDispatchEntry = canDispatchEntry(consumer, entry, readType, stickyKeyHash);
if (!canDispatchEntry) {
if(blockedByHash != null){
blockedByHash.setTrue();
}
// decrement the permits for the consumer
permits.decrement();
// allow the entry to be dispatched
dispatchEntry = true;
}
Copy link
Member

Choose a reason for hiding this comment

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

This logic is not correct. Do you spot the problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you explain it in detail? @lhotari

Copy link
Member

Choose a reason for hiding this comment

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

For effective contributions, it is necessary to run tests and use tests to provide feedback. Did you check my previous advice about Personal CI? When you know what tests fail, you can then locally run a single unit test in your IDE. Have you already tried this?

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

Please follow instructions to first get a CI pass with "Personal CI" in your forked repository: https://pulsar.apache.org/contribute/personal-ci/ . You will be able to get automated CI feedback on your own without requiring assistance from Pulsar contributors. It's necessary to latest changes from master branch to get most recent CI fixes. We have a lot of flaky tests, so some test failures could be flaky ones. Rerun failed builds in GitHub Actions CI if this happens. In your personal CI you will have full control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants