Fix hang in test for "too many fields" dep. check (#42909)

This commit fixes a rare case where the method to randomly generate a
very large mapping could enter an infinite loop.
This commit is contained in:
Gordon Brown 2019-06-06 08:28:32 -06:00 committed by GitHub
parent 1f1868a294
commit e35b240a43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -370,7 +370,7 @@ public class IndexDeprecationChecksTests extends ESTestCase {
mappingBuilder.startObject("properties");
{
int subfields = randomIntBetween(1, 10);
while (existingFieldNames.size() < subfields) {
while (existingFieldNames.size() < subfields && fieldCount.get() <= fieldLimit) {
addRandomField(existingFieldNames, fieldLimit, mappingBuilder, fieldCount);
}
}