Since 3.17.0, and the new CachedRandomBits implementation, it is no longer
possible to create random strings longer than about 60M characters.  It's
not exact, as the overflow will happen at a random point depending on the
number of  rejections.  The attached test will always generate
an java.lang.ArrayIndexOutOfBoundsException: Index -268435456 as the int
wraps around due to rejections

I've got a simple fix and will create an issue and PR if you feel it's
worth fixing, otherwise I'll document the limit as you should probably
use org.apache.commons.text.RandomStringGenerator.generate()
for huge strings.

Regards,
James

@Test
public void testHugeStrings() {
    final int expectedLength = 64_000_000;
    final String hugeString = RandomStringUtils.random(expectedLength);
    assertEquals(expectedLength, hugeString.length(),
"hugeString.length() == expectedLength");
}

Reply via email to