Skip to content

Commit 8f9f640

Browse files
authored
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.
1 parent 04a7a19 commit 8f9f640

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,8 @@ private static void addRandomField(List<String> existingFieldNames, final int fi
614614
if (rarely()) {
615615
mappingBuilder.startObject("properties");
616616
{
617-
int subfields = randomIntBetween(1,10);
618-
while (existingFieldNames.size() < subfields) {
617+
int subfields = randomIntBetween(1, 10);
618+
while (existingFieldNames.size() < subfields && fieldCount.get() <= fieldLimit) {
619619
addRandomField(existingFieldNames, fieldLimit, mappingBuilder, fieldCount);
620620
}
621621
}

0 commit comments

Comments
 (0)