1010
1111import org .apache .lucene .tests .util .English ;
1212import org .elasticsearch .action .index .IndexRequestBuilder ;
13+ import org .elasticsearch .action .search .SearchRequestBuilder ;
14+ import org .elasticsearch .action .search .SearchResponse ;
1315import org .elasticsearch .common .settings .Settings ;
1416import org .elasticsearch .core .TimeValue ;
1517import org .elasticsearch .test .ESIntegTestCase ;
@@ -33,7 +35,6 @@ protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
3335 .build ();
3436 }
3537
36- // see issue #5165 - this test fails each time without the fix in pull #5170
3738 public void testStressReaper () throws ExecutionException , InterruptedException {
3839 int num = randomIntBetween (100 , 150 );
3940 IndexRequestBuilder [] builders = new IndexRequestBuilder [num ];
@@ -44,7 +45,16 @@ public void testStressReaper() throws ExecutionException, InterruptedException {
4445 indexRandom (true , builders );
4546 final int iterations = scaledRandomIntBetween (500 , 1000 );
4647 for (int i = 0 ; i < iterations ; i ++) {
47- assertHitCountAndNoFailures (prepareSearch ("test" ).setQuery (matchAllQuery ()).setSize (num ), num );
48+ SearchResponse response = null ;
49+ try {
50+ SearchRequestBuilder searchRequestBuilder = prepareSearch ("test" ).setQuery (matchAllQuery ()).setSize (num );
51+ response = searchRequestBuilder .get ();
52+ assertHitCountAndNoFailures (searchRequestBuilder , num );
53+ } finally {
54+ if (response != null ) {
55+ response .decRef ();
56+ }
57+ }
4858 }
4959 }
5060}
0 commit comments