From 6b46bf13f04cd01cb51d3d11ccf259755b7f7253 Mon Sep 17 00:00:00 2001 From: Florian Hopf Date: Sun, 19 Jun 2016 23:25:18 +0200 Subject: [PATCH] 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 --- .../org/elasticsearch/cluster/service/ClusterService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java b/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java index 7573f260a54..50c91665485 100644 --- a/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java +++ b/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java @@ -237,7 +237,11 @@ public class ClusterService extends AbstractLifecycleComponent { * 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() {