diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java index 34e85a8952701..0655da1db08f3 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java @@ -370,7 +370,7 @@ private static void addRandomField(List existingFieldNames, final int fi mappingBuilder.startObject("properties"); { int subfields = randomIntBetween(1, 10); - while (existingFieldNames.size() < subfields) { + while (existingFieldNames.size() < subfields && fieldCount.get() <= fieldLimit) { addRandomField(existingFieldNames, fieldLimit, mappingBuilder, fieldCount); } }