Skip to content

Commit f38385e

Browse files
Fix Leaking Listener When Closing NodeClient (#55676) (#55864)
If a node client (or rather its underlying node) is closed then any executions on it will just quietly fail as happens in #55660 via closing the nodes on the test thread and asynchronously using a node client. Closes #55660
1 parent 3b211c1 commit f38385e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

server/src/main/java/org/elasticsearch/transport/TransportService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,9 +747,11 @@ private <T extends TransportResponse> void sendRequestInternal(final Transport.C
747747
timeoutHandler.cancel();
748748
}
749749
// callback that an exception happened, but on a different thread since we don't
750-
// want handlers to worry about stack overflows
750+
// want handlers to worry about stack overflows. In the special case of running into a closing node we run on the current
751+
// thread on a best effort basis though.
751752
final SendRequestTransportException sendRequestException = new SendRequestTransportException(node, action, e);
752-
threadPool.executor(ThreadPool.Names.GENERIC).execute(new AbstractRunnable() {
753+
final String executor = lifecycle.stoppedOrClosed() ? ThreadPool.Names.SAME : ThreadPool.Names.GENERIC;
754+
threadPool.executor(executor).execute(new AbstractRunnable() {
753755
@Override
754756
public void onRejection(Exception e) {
755757
// if we get rejected during node shutdown we don't wanna bubble it up

0 commit comments

Comments
 (0)