Skip to content

Commit bc676f3

Browse files
[Test] Fix AsyncSearchResponse resource leak in security tests (#107809) (#107819)
Closes #107759
1 parent b9f277e commit bc676f3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

x-pack/plugin/async-search/qa/security/src/javaRestTest/java/org/elasticsearch/xpack/search/AsyncSearchSecurityIT.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,19 +223,21 @@ private void testCase(String user, String other) throws Exception {
223223
private SearchHit[] getSearchHits(String asyncId, String user) throws IOException {
224224
final Response resp = getAsyncSearch(asyncId, user);
225225
assertOK(resp);
226-
SearchResponse searchResponse = ASYNC_SEARCH_RESPONSE_PARSER.apply(
226+
AsyncSearchResponse asyncSearchResponse = ASYNC_SEARCH_RESPONSE_PARSER.apply(
227227
XContentHelper.createParser(
228228
NamedXContentRegistry.EMPTY,
229229
LoggingDeprecationHandler.INSTANCE,
230230
new BytesArray(EntityUtils.toByteArray(resp.getEntity())),
231231
XContentType.JSON
232232
),
233233
null
234-
).getSearchResponse();
234+
);
235+
SearchResponse searchResponse = asyncSearchResponse.getSearchResponse();
235236
try {
236237
return searchResponse.getHits().asUnpooled().getHits();
237238
} finally {
238239
searchResponse.decRef();
240+
asyncSearchResponse.decRef();
239241
}
240242
}
241243

0 commit comments

Comments
 (0)