Skip to content

Commit b9c0d44

Browse files
authored
Catch exceptions and inform handler in RemoteClusterConnection#collectNodes (#26725)
This adds a missing catch block to invoke the action listener instead of bubbeling up the exception. Closes #26700
1 parent 34662c9 commit b9c0d44

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

core/src/main/java/org/elasticsearch/transport/RemoteClusterConnection.java

+13-9
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,19 @@ public String executor() {
230230
}
231231
});
232232
};
233-
if (connectedNodes.size() == 0) {
234-
// just in case if we are not connected for some reason we try to connect and if we fail we have to notify the listener
235-
// this will cause some back pressure on the search end and eventually will cause rejections but that's fine
236-
// we can't proceed with a search on a cluster level.
237-
// in the future we might want to just skip the remote nodes in such a case but that can already be implemented on the
238-
// caller end since they provide the listener.
239-
ensureConnected(ActionListener.wrap((x) -> runnable.run(), listener::onFailure));
240-
} else {
241-
runnable.run();
233+
try {
234+
if (connectedNodes.size() == 0) {
235+
// just in case if we are not connected for some reason we try to connect and if we fail we have to notify the listener
236+
// this will cause some back pressure on the search end and eventually will cause rejections but that's fine
237+
// we can't proceed with a search on a cluster level.
238+
// in the future we might want to just skip the remote nodes in such a case but that can already be implemented on the
239+
// caller end since they provide the listener.
240+
ensureConnected(ActionListener.wrap((x) -> runnable.run(), listener::onFailure));
241+
} else {
242+
runnable.run();
243+
}
244+
} catch (Exception ex) {
245+
listener.onFailure(ex);
242246
}
243247
}
244248

0 commit comments

Comments
 (0)