[Bug] MessageQueuePenalizer throws when a priority group is empty
- Dominant language
- Java
- Stars
- 22.6k
- Forks
- 12k
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 27
Description
### Before Creating the Bug Report
- [x] I have searched the existing issues and pull requests.
### Runtime platform environment
N/A
### RocketMQ version
develop branch
### JDK Version
N/A
### Describe the Bug
`MessageQueuePenalizer.selectLeastPenaltyWithPriority()` delegates each priority bucket to `selectLeastPenalty()` and immediately dereferences the returned pair.
`selectLeastPenalty()` explicitly returns `null` when the queue list is null or empty. Therefore, if `queuesWithPriority` contains an empty bucket before or between non-empty buckets, `selectLeastPenaltyWithPriority()` throws `NullPointerException` instead of skipping that bucket or returning a stable empty result.
### Steps to Reproduce
1. Call `selectLeastPenaltyWithPriority()` with more than one priority group.
2. Include an empty priority group, for example `[[], [queue-0]]`.
3. Observe that the method dereferences `queueAndPenalty.getRight()` even though `queueAndPenalty` is null.
### What Did You Expect to See?
Empty priority groups should be ignored. If all priority groups are empty, the method should return `null`, matching `selectLeastPenalty()` behavior.
### What Did You See Instead?
`NullPointerException` can be thrown when a priority bucket is empty.
### Additional Context
This is a small runtime robustness issue in Proxy route queue selection.
Contributor guide
Research direction
Start at MessageQueuePenalizer.selectLeastPenaltyWithPriority() and follow its calls to selectLeastPenalty(), especially the handling of the returned pair. Reproduce the case with an empty priority group before or between non-empty groups, then verify that empty groups are ignored and that all-empty input returns null without throwing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100