ppkarwasz commented on code in PR #1379: URL: https://github.com/apache/commons-lang/pull/1379#discussion_r2086199080
########## src/main/java/org/apache/commons/lang3/RandomStringUtils.java: ########## @@ -97,6 +97,7 @@ public class RandomStringUtils { private static final int ASCII_9 = '9'; private static final int ASCII_A = 'A'; private static final int ASCII_z = 'z'; + private static final int MAX_CACHE_SIZE = 60_000_000; Review Comment: Rejections are not a problem. Theoretically `CachedRandomBits#nextBits` should be able to produce an unlimited sequence of integers without `bitIndex` ever overflowing. The `bitIndex` counter is reset to `0` when it reaches `8 * cache.length`: https://github.com/apache/commons-lang/blob/a41a57e58e73242c1fc5dd1f8e53bc883558331d/src/main/java/org/apache/commons/lang3/CachedRandomBits.java#L84-L90 The problem you are experiencing only occurs if `cache.length = (count * gapBits + 3) / 5 + 10` is `268_435_456` or higher. For `gapBits = 21` (i.e. no constraints on the Unicode characters to use), an overflow should happen if `count` is at least `63_913_202`. -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org