Akshat-coder2106 opened a new pull request, #1537:
URL: https://github.com/apache/commons-lang/pull/1537
## LANG-1801: Validate start/end bounds only for explicit char ranges
### Summary
This change adds validation for the `start` and `end` parameters in
`RandomStringUtils.random(...)` **only when a custom `chars` array is provided
and an explicit range is used**.
### Problem
When `chars` is supplied, invalid ranges such as:
- `end <= start`
- negative indices
- ranges exceeding `chars.length`
can lead to unexpected behavior. These cases were not consistently validated.
At the same time, the documented sentinel behavior
`start == 0 && end == 0` must continue to work as intended.
### Solution
- Adds explicit validation of `start` and `end` **only** when:
- `chars != null`, and
- a non-default range is provided
- Preserves the existing `(start == 0 && end == 0)` behavior
- Does not change behavior for existing convenience methods
### Tests
- Updates and adds unit tests in `RandomStringUtilsTest`
- Tests cover invalid range scenarios when `chars` is provided
- `mvn test` passes locally
--
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]