Skip to content

Commit e35b240

Browse files
authored
Fix hang in test for "too many fields" dep. check (elastic#42909)
This commit fixes a rare case where the method to randomly generate a very large mapping could enter an infinite loop.
1 parent 1f1868a commit e35b240

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ private static void addRandomField(List<String> existingFieldNames, final int fi
370370
mappingBuilder.startObject("properties");
371371
{
372372
int subfields = randomIntBetween(1, 10);
373-
while (existingFieldNames.size() < subfields) {
373+
while (existingFieldNames.size() < subfields && fieldCount.get() <= fieldLimit) {
374374
addRandomField(existingFieldNames, fieldLimit, mappingBuilder, fieldCount);
375375
}
376376
}

0 commit comments

Comments
 (0)