Skip to content

Commit

Permalink
Close listener refs in finally block (#108830) (#108837)
Browse files Browse the repository at this point in the history
We will need to acquire a new listener in the catch block; therefore, we 
should not release the listenerRefs in the try-with-resources block,
which is executed before the catch block.

Relates #108580
  • Loading branch information
dnhatn committed May 20, 2024
1 parent 217fb4a commit 6db2321
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ private void runComputeOnDataNode(
final RefCountingListener listenerRefs = new RefCountingListener(
ActionListener.runBefore(listener.map(unused -> new ComputeResponse(collectedProfiles)), responseHeadersCollector::finish)
);
try (listenerRefs) {
try {
final AtomicBoolean cancelled = new AtomicBoolean();
// run compute with target shards
var internalSink = exchangeService.createSinkHandler(request.sessionId(), request.pragmas().exchangeBufferSize());
Expand Down Expand Up @@ -746,6 +746,8 @@ private void runComputeOnDataNode(
exchangeService.finishSinkHandler(externalId, e);
exchangeService.finishSinkHandler(request.sessionId(), e);
listenerRefs.acquire().onFailure(e);
} finally {
listenerRefs.close();
}
}

Expand Down

0 comments on commit 6db2321

Please sign in to comment.