Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[ISSUE #1101] fix "subtract with overflow" bug for allocate_message_queue_averagely #1102

Merged
merged 3 commits into from
Nov 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@
} else {
index * average_size + mod_val
};
let range = average_size.min(mq_all.len() - start_index);
//let range = average_size.min(mq_all.len() - start_index);
//fix the bug " subtract with overflow" caused by (mq_all.len() - start_index )
let mut range: usize = 0;
if mq_all.len() > start_index {
range = average_size.min(mq_all.len() - start_index);

Check warning on line 59 in rocketmq-client/src/consumer/rebalance_strategy/allocate_message_queue_averagely.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-client/src/consumer/rebalance_strategy/allocate_message_queue_averagely.rs#L57-L59

Added lines #L57 - L59 were not covered by tests
}
//in case of mq_all.len() < start_index , means the customers is much more than queue
// so let range ==0 ,the for loop not work, and then no queue alloced to this customerID
for i in 0..range {
result.push(mq_all[start_index + i].clone());
}
Expand Down
Loading