Skip to content

Commit

Permalink
Fix SearchResponse leaks in cross cluster access tests (elastic#105039)
Browse files Browse the repository at this point in the history
Fixes ref counting of SearchResponse in cross cluster access tests.

Resolves elastic#105038
  • Loading branch information
slobodanadamovic authored Feb 2, 2024
1 parent a982404 commit 7c2fdff
Showing 1 changed file with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.core.ReleasableRef;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.aggregations.InternalAggregations;
Expand Down Expand Up @@ -1148,24 +1149,28 @@ private static MockTransportService startTransport(
capturedHeaders.add(
new CapturedActionWithHeaders(task.getAction(), Map.copyOf(threadPool.getThreadContext().getHeaders()))
);
channel.sendResponse(
new SearchResponse(
SearchHits.empty(new TotalHits(0, TotalHits.Relation.EQUAL_TO), Float.NaN),
InternalAggregations.EMPTY,
null,
false,
null,
null,
1,
null,
1,
1,
0,
100,
ShardSearchFailure.EMPTY_ARRAY,
SearchResponse.Clusters.EMPTY
try (
var searchResponseRef = ReleasableRef.of(
new SearchResponse(
SearchHits.empty(new TotalHits(0, TotalHits.Relation.EQUAL_TO), Float.NaN),
InternalAggregations.EMPTY,
null,
false,
null,
null,
1,
null,
1,
1,
0,
100,
ShardSearchFailure.EMPTY_ARRAY,
SearchResponse.Clusters.EMPTY
)
)
);
) {
channel.sendResponse(searchResponseRef.get());
}
}
);
service.start();
Expand Down

0 comments on commit 7c2fdff

Please sign in to comment.