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
This commit is contained in:
Simon Willnauer 2017-09-20 17:53:12 +02:00 committed by GitHub
parent 34662c9e6d
commit b9c0d4447c
1 changed files with 13 additions and 9 deletions

View File

@ -230,15 +230,19 @@ final class RemoteClusterConnection extends AbstractComponent implements Transpo
}
});
};
if (connectedNodes.size() == 0) {
// 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
// this will cause some back pressure on the search end and eventually will cause rejections but that's fine
// we can't proceed with a search on a cluster level.
// in the future we might want to just skip the remote nodes in such a case but that can already be implemented on the
// caller end since they provide the listener.
ensureConnected(ActionListener.wrap((x) -> runnable.run(), listener::onFailure));
} else {
runnable.run();
try {
if (connectedNodes.size() == 0) {
// 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
// this will cause some back pressure on the search end and eventually will cause rejections but that's fine
// we can't proceed with a search on a cluster level.
// in the future we might want to just skip the remote nodes in such a case but that can already be implemented on the
// caller end since they provide the listener.
ensureConnected(ActionListener.wrap((x) -> runnable.run(), listener::onFailure));
} else {
runnable.run();
}
} catch (Exception ex) {
listener.onFailure(ex);
}
}