Fix hang in test for "too many fields" dep. check
This commit fixes a rare case where the method to randomly generate a
very large mapping could enter an infinite loop.
@@ -615,7 +615,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);
}
}
