RandomDocumentPicks#randomFieldName can produce invalid field name (#28419)
This change makes sure that this function does not create field names that end with a '.', more precisely it only allows alpha-numeric characters to compose the leaf field name. Closes #27373
This commit is contained in:
parent
202d28be86
commit
7edb978256
|
@ -43,12 +43,16 @@ public final class RandomDocumentPicks {
|
|||
public static String randomFieldName(Random random) {
|
||||
int numLevels = RandomNumbers.randomIntBetween(random, 1, 5);
|
||||
StringBuilder fieldName = new StringBuilder();
|
||||
for (int i = 0; i < numLevels; i++) {
|
||||
for (int i = 0; i < numLevels-1; i++) {
|
||||
if (i > 0) {
|
||||
fieldName.append('.');
|
||||
}
|
||||
fieldName.append(randomString(random));
|
||||
}
|
||||
if (numLevels > 1) {
|
||||
fieldName.append('.');
|
||||
}
|
||||
fieldName.append(randomLeafFieldName(random));
|
||||
return fieldName.toString();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue