From b289f6c007d36997cadc97560a2dbfd416ec6b88 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Thu, 6 Jun 2019 08:28:32 -0600 Subject: [PATCH] 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. --- .../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 4896bf715a98e..882151553a1b6 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 @@ -132,7 +132,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); } }