From 3401f91cd19c80eada9acc8177b9ee249feb3e7f Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Wed, 5 Jun 2019 17:17:22 -0600 Subject: [PATCH] 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. --- .../xpack/deprecation/IndexDeprecationChecksTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); } }