Skip to content

Commit b289f6c

Browse files
committed
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 0dec7a4 commit b289f6c

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private static void addRandomField(List<String> existingFieldNames, final int fi
132132
mappingBuilder.startObject("properties");
133133
{
134134
int subfields = randomIntBetween(1, 10);
135-
while (existingFieldNames.size() < subfields) {
135+
while (existingFieldNames.size() < subfields && fieldCount.get() <= fieldLimit) {
136136
addRandomField(existingFieldNames, fieldLimit, mappingBuilder, fieldCount);
137137
}
138138
}

0 commit comments

Comments
 (0)