From f2cb5c61a509499a641938141195ed3e1083b972 Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Tue, 1 Dec 2020 06:06:50 +0100 Subject: [PATCH] Fix NPE in ClusterInfoService Store stats can be `null` if e.g. the shard was already closed when the stats where retrieved. Don't record those shards in the sizes map to fix an NPE in this case. --- .../org/elasticsearch/cluster/InternalClusterInfoService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java b/server/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java index 0d6f8e729d673..1991b37a6e0f1 100644 --- a/server/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java +++ b/server/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java @@ -331,6 +331,9 @@ static void buildShardLevelInfo(Logger logger, ShardStats[] stats, ImmutableOpen newShardRoutingToDataPath.put(shardRouting, s.getDataPath()); final StoreStats storeStats = s.getStats().getStore(); + if (storeStats == null) { + continue; + } final long size = storeStats.sizeInBytes(); final long reserved = storeStats.getReservedSize().getBytes();