Skip to content

Commit 763332e

Browse files
authored
close properly byte stream on failure: (#137810)
1 parent f2afb88 commit 763332e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,18 +869,26 @@ void onShardDone() {
869869
var channelListener = new ChannelActionListener<>(channel);
870870
RecyclerBytesStreamOutput out = dependencies.transportService.newNetworkBytesStream();
871871
out.setTransportVersion(channel.getVersion());
872+
873+
boolean success = false;
872874
try (queryPhaseResultConsumer) {
873875
Exception reductionFailure = queryPhaseResultConsumer.failure.get();
874876
if (reductionFailure == null) {
875877
writeSuccessfulResponse(out);
876878
} else {
877879
writeReductionFailureResponse(out, reductionFailure);
878880
}
881+
success = true;
879882
} catch (IOException e) {
880883
releaseAllResultsContexts();
881884
channelListener.onFailure(e);
882885
return;
886+
} finally {
887+
if (success == false) {
888+
out.close();
889+
}
883890
}
891+
884892
ActionListener.respondAndRelease(
885893
channelListener,
886894
new BytesTransportResponse(out.moveToBytesReference(), out.getTransportVersion())

0 commit comments

Comments
 (0)