garydgregory commented on code in PR #1703:
URL: https://github.com/apache/commons-lang/pull/1703#discussion_r3409495109
##########
src/main/java/org/apache/commons/lang3/RandomStringUtils.java:
##########
@@ -296,7 +296,9 @@ public static String random(int count, int start, int end,
final boolean letters
if (letters && digits && start <= ASCII_0 && end >= ASCII_z + 1) {
return random(count, 0, 0, false, false, ALPHANUMERICAL_CHARS,
random);
}
- if (digits && end <= ASCII_0 || letters && end <= ASCII_A) {
+ // Only reject when none of the requested categories is reachable;
otherwise a letters && digits
+ // request would throw on a range that holds one category but not
the other (e.g. [ASCII_0, ASCII_A)).
+ if ((!digits || end <= ASCII_0) && (!letters || end <= ASCII_A) &&
(digits || letters)) {
throw new IllegalArgumentException(
String.format("Parameter end (%,d) must be greater
than (%,d) for generating digits or greater than (%,d) for generating
letters.", end,
Review Comment:
@alhudz
Please review the comment above. TY!
--
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]