Skip to content

Commit

Permalink
decref searchhits
Browse files Browse the repository at this point in the history
  • Loading branch information
pmpailis committed Oct 3, 2024
1 parent 1e6f3bc commit 957fb65
Showing 1 changed file with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,18 @@ void sendExecuteMultiSearch(MultiSearchRequest request, SearchTask task, ActionL
SearchHit hit = new SearchHit(1, "ID");
hit.setDocumentField("someField", new DocumentField("someField", Collections.singletonList("foo")));
SearchHits hits = new SearchHits(new SearchHit[] { hit }, new TotalHits(1, TotalHits.Relation.EQUAL_TO), 1.0F);
ExpandSearchPhase phase = new ExpandSearchPhase(mockSearchPhaseContext, hits, () -> new SearchPhase("test") {
@Override
public void run() {
mockSearchPhaseContext.sendSearchResponse(new SearchResponseSections(hits, null, null, false, null, null, 1), null);
}
});
phase.run();
mockSearchPhaseContext.assertNoFailure();
try {
ExpandSearchPhase phase = new ExpandSearchPhase(mockSearchPhaseContext, hits, () -> new SearchPhase("test") {
@Override
public void run() {
mockSearchPhaseContext.sendSearchResponse(new SearchResponseSections(hits, null, null, false, null, null, 1), null);
}
});
phase.run();
mockSearchPhaseContext.assertNoFailure();
} finally {
hits.decRef();
}
} finally {
var resp = mockSearchPhaseContext.searchResponse.get();
if (resp != null) {
Expand Down Expand Up @@ -387,17 +391,21 @@ void sendExecuteMultiSearch(MultiSearchRequest request, SearchTask task, ActionL
SearchHit hit = new SearchHit(1, "ID");
hit.setDocumentField("someField", new DocumentField("someField", Collections.singletonList("foo")));
SearchHits hits = new SearchHits(new SearchHit[] { hit }, new TotalHits(1, TotalHits.Relation.EQUAL_TO), 1.0F);
ExpandSearchPhase phase = new ExpandSearchPhase(mockSearchPhaseContext, hits, () -> new SearchPhase("test") {
@Override
public void run() {
mockSearchPhaseContext.sendSearchResponse(
new SearchResponseSections(hits, null, null, false, null, null, 1),
new AtomicArray<>(0)
);
}
});
phase.run();
mockSearchPhaseContext.assertNoFailure();
try {
ExpandSearchPhase phase = new ExpandSearchPhase(mockSearchPhaseContext, hits, () -> new SearchPhase("test") {
@Override
public void run() {
mockSearchPhaseContext.sendSearchResponse(
new SearchResponseSections(hits, null, null, false, null, null, 1),
new AtomicArray<>(0)
);
}
});
phase.run();
mockSearchPhaseContext.assertNoFailure();
} finally {
hits.decRef();
}
} finally {
var resp = mockSearchPhaseContext.searchResponse.get();
if (resp != null) {
Expand Down

0 comments on commit 957fb65

Please sign in to comment.