diff --git a/core/src/test/java/org/elasticsearch/index/query/support/InnerHitBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/support/InnerHitBuilderTests.java index 117a3704c29..a16a2bb26f8 100644 --- a/core/src/test/java/org/elasticsearch/index/query/support/InnerHitBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/support/InnerHitBuilderTests.java @@ -236,10 +236,12 @@ public class InnerHitBuilderTests extends ESTestCase { })); break; case 9: - copy.setSorts(randomValueOtherThan(copy.getSorts(), () -> { - return randomListStuff(16, - () -> SortBuilders.fieldSort(randomAsciiOfLengthBetween(5, 20)).order(randomFrom(SortOrder.values()))); - })); + final List> sortBuilders = randomValueOtherThan(copy.getSorts(), () -> { + List> builders = randomListStuff(16, + () -> SortBuilders.fieldSort(randomAsciiOfLengthBetween(5, 20)).order(randomFrom(SortOrder.values()))); + return builders; + }); + copy.setSorts(sortBuilders); break; case 10: copy.setHighlightBuilder(randomValueOtherThan(copy.getHighlightBuilder(),