Skip to content

Commit 43988a0

Browse files
authored
[9.2] close properly byte stream on failure: (#137810) (#137868)
* update code * Update SearchQueryThenFetchAsyncAction.java
1 parent 209f7cc commit 43988a0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

server/src/main/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncAction.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,17 +843,24 @@ void onShardDone() {
843843
var channelListener = new ChannelActionListener<>(channel);
844844
RecyclerBytesStreamOutput out = dependencies.transportService.newNetworkBytesStream();
845845
out.setTransportVersion(channel.getVersion());
846+
847+
boolean success = false;
846848
try (queryPhaseResultConsumer) {
847849
Exception reductionFailure = queryPhaseResultConsumer.failure.get();
848850
if (reductionFailure == null) {
849851
writeSuccessfulResponse(out);
850852
} else {
851853
writeReductionFailureResponse(out, reductionFailure);
852854
}
855+
success = true;
853856
} catch (IOException e) {
854857
releaseAllResultsContexts();
855858
channelListener.onFailure(e);
856859
return;
860+
} finally {
861+
if (success == false) {
862+
out.close();
863+
}
857864
}
858865
ActionListener.respondAndRelease(channelListener, new BytesTransportResponse(out.moveToBytesReference()));
859866
}

0 commit comments

Comments
 (0)