alhudz opened a new pull request, #1751:
URL: https://github.com/apache/commons-lang/pull/1751

   `Repro:` `new FluentBitSet().setInclusive(0, Integer.MAX_VALUE)` throws 
`IndexOutOfBoundsException: toIndex < 0: -2147483648`, and so does 
`setInclusive(Integer.MAX_VALUE, Integer.MAX_VALUE)`.
   
   `Cause:` `setInclusive` converts the inclusive `toIndex` into `BitSet.set`'s 
exclusive upper bound with `toIndex + 1`, which overflows to 
`Integer.MIN_VALUE` when `toIndex` is `Integer.MAX_VALUE`. The Javadoc only 
documents a throw when an index is negative or `fromIndex` is larger than 
`toIndex`, so a legal top-of-range call throws instead of setting the bits.
   
   `Fix:` special-case `toIndex == Integer.MAX_VALUE` so the range and the top 
bit are set without the overflowing increment; every other input keeps the 
existing single `set` call. The regression test is guarded by 
`@EnabledIfSystemProperty(named = "test.large.heap", matches = "true")` like 
the existing large-heap test, since bit `Integer.MAX_VALUE` needs the full 
backing array; it fails on the current code and passes with the fix.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to