Skip to content

MINOR: Prevent overflow in CreateTopics partition validation#22722

Open
coderbruis wants to merge 2 commits into
apache:trunkfrom
coderbruis:minor-create-topics-partition-count-overflow
Open

MINOR: Prevent overflow in CreateTopics partition validation#22722
coderbruis wants to merge 2 commits into
apache:trunkfrom
coderbruis:minor-create-topics-partition-count-overflow

Conversation

@coderbruis

Copy link
Copy Markdown

This patch updates the CreateTopics partition count validation.

Changes:

  • Update the validation comment to state that a request may create at most MAX_PARTITIONS_PER_BATCH partitions.
  • Use a long counter to prevent integer overflow when accumulating partition counts from the request.
  • Move the limit check inside the loop so that oversized requests fail as soon as the limit is exceeded.

Test:

  • Add testTotalNumberOfPartitionsValidationDoesNotOverflow to cover a CreateTopics request large enough to overflow an int.

@github-actions github-actions Bot added triage PRs from the community kraft small Small PRs labels Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kraft small Small PRs triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant