Skip to content

Commit 4bd7477

Browse files
Apply suggestion from @labkey-tchad
Co-authored-by: Trey Chadick <[email protected]>
1 parent 1fbff7c commit 4bd7477

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/org/labkey/test/util/TestDataGenerator.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,11 @@ public static List<String> randomTextChoice(int size)
504504
{
505505
Set<String> textChoices = new LinkedHashSet<>();
506506
int attempts = 0;
507-
while (textChoices.size() < size)
508-
{
509-
if (++attempts >= MAX_RANDOM_TRIES)
510-
throw new IllegalStateException("Failed to generate " + size + " unique text choices after " + MAX_RANDOM_TRIES + " attempts");
507+
final int maxTries = Math.max(MAX_RANDOM_TRIES, size * 2);
508+
while (textChoices.size() < size)
509+
{
510+
if (++attempts >= maxTries)
511+
throw new IllegalStateException("Failed to generate " + size + " unique text choices after " + maxTries + " attempts");
511512
String generated = randomString(randomInt(1, 25), ";").trim();
512513
if (!generated.isEmpty())
513514
{

0 commit comments

Comments
 (0)