ppkarwasz commented on code in PR #1379: URL: https://github.com/apache/commons-lang/pull/1379#discussion_r2100949198
########## src/main/java/org/apache/commons/lang3/RandomStringUtils.java: ########## @@ -329,7 +329,10 @@ public static String random(int count, int start, int end, final boolean letters // Ideally the cache size depends on multiple factor, including the cost of generating x bytes // of randomness as well as the probability of rejection. It is however not easy to know // those values programmatically for the general case. - final CachedRandomBits arb = new CachedRandomBits((count * gapBits + 3) / 5 + 10, random); + // For huge strings the padding required can cause an overflow + // 63_913_201 is the highest x such that (21x + 3) / 5 + 10 < 0x0FFF_FFFF. + final long cacheSize = Math.min((count * gapBits + 3) / 5 + 10, Integer.MAX_VALUE / 5); Review Comment: ```suggestion final long cacheSize = Math.min((long) count * gapBits + 3, Integer.MAX_VALUE) / 5 + 10; ``` -- 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