Throw if the local node is not set

This commit adds an IllegalStateException if attempting to get the local
node from the cluster service when it is not set.

Relates #18963
This commit is contained in:
Florian Hopf 2016-06-19 23:25:18 +02:00 committed by Jason Tedor
parent 92bc29266b
commit 6b46bf13f0
1 changed files with 5 additions and 1 deletions

View File

@ -237,7 +237,11 @@ public class ClusterService extends AbstractLifecycleComponent<ClusterService> {
* The local node.
*/
public DiscoveryNode localNode() {
return clusterState.getNodes().getLocalNode();
DiscoveryNode localNode = clusterState.getNodes().getLocalNode();
if (localNode == null) {
throw new IllegalStateException("No local node found. Is the node started?");
}
return localNode;
}
public OperationRouting operationRouting() {