Skip to content

Conversation

rozza
Copy link
Member

@rozza rozza commented Sep 24, 2025

Eliminate unnecessary killCursors command when batchSize == limit can overflow if using Integer.MAX_VALUE for both.

JAVA-5667
JAVA-5970

Eliminate unnecessary killCursors command when batchSize == limit
can overflow if using Integer.MAX_VALUE for both.

JAVA-5667
JAVA-5970
@rozza rozza requested a review from a team as a code owner September 24, 2025 10:24
@rozza rozza requested review from nhachicha and stIncMale and removed request for a team and nhachicha September 24, 2025 10:24
@rozza rozza requested review from nhachicha and Copilot and removed request for stIncMale September 30, 2025 14:28
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an integer overflow issue in the FindOperation when both batchSize and limit are set to Integer.MAX_VALUE. The fix prevents incrementing the effective batch size when it would cause overflow, eliminating unnecessary killCursors commands.

  • Adds overflow protection in FindOperation.getCommand() by checking that effectiveBatchSize is less than Integer.MAX_VALUE before incrementing
  • Adds comprehensive unit tests to validate the behavior with various combinations of batchSize and limit values including edge cases with Integer.MAX_VALUE

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
FindOperation.java Adds overflow check to prevent incrementing batch size when it equals Integer.MAX_VALUE
FindOperationUnitSpecification.groovy Adds unit test covering batch size and limit combinations including Integer.MAX_VALUE edge cases

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant