Skip to content

Commit df5ce63

Browse files
authored
Prevent StringIndexOutOfBoundsException when generating field names (#2552)
1 parent 787d439 commit df5ce63

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ public static String randomFieldName(@NotNull String part, int numStartChars, in
582582
String randomFieldName = randomName(part, numStartChars, numEndChars, chars, exclusion);
583583

584584
// Avoid generating fields names with reserved substitution format patterns. e.g. ":Date" or ":First"
585-
if (numStartChars > 0 && randomFieldName.charAt(numStartChars - 1) == ':' &&
585+
if (numStartChars > 0 && part.length() >= 4 && randomFieldName.charAt(numStartChars - 1) == ':' &&
586586
StringUtils.isAlpha(part.substring(0, 4))) // The shortest pattern is four characters (see org.labkey.api.util.SubstitutionFormat.getFormatNames)
587587
{
588588
String regenExclusion = Objects.requireNonNullElse(exclusion, "") + ":";

0 commit comments

Comments
 (0)