diff --git a/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java index 4d313baecc1..5f8c847e41e 100644 --- a/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java @@ -350,8 +350,9 @@ public class InnerHitBuilderTests extends ESTestCase { if (instance.getStoredFieldsContext() == null || randomBoolean()) { List previous = instance.getStoredFieldsContext() == null ? Collections.emptyList() : instance.getStoredFieldsContext().fieldNames(); - instance.setStoredFieldNames(randomValueOtherThan(previous, - () -> randomListStuff(16, () -> randomAsciiOfLengthBetween(1, 16)))); + List newValues = randomValueOtherThan(previous, + () -> randomListStuff(1, 16, () -> randomAsciiOfLengthBetween(1, 16))); + instance.setStoredFieldNames(newValues); } else { instance.getStoredFieldsContext().addFieldName(randomAsciiOfLengthBetween(1, 16)); } @@ -377,7 +378,11 @@ public class InnerHitBuilderTests extends ESTestCase { } static List randomListStuff(int maxSize, Supplier valueSupplier) { - int size = randomIntBetween(0, maxSize); + return randomListStuff(0, maxSize, valueSupplier); + } + + static List randomListStuff(int minSize, int maxSize, Supplier valueSupplier) { + int size = randomIntBetween(minSize, maxSize); List list = new ArrayList<>(size); for (int i = 0; i < size; i++) { list.add(valueSupplier.get());