From 0603be3a2862fe2685939d1cea98f4ed843c6c2a Mon Sep 17 00:00:00 2001 From: Rampreeth Ethiraj Date: Thu, 27 Jun 2024 21:34:59 +0530 Subject: [PATCH] Segment Replication stats throwing NPE when shards are unassigned or are in delayed allocation phase Signed-off-by: Rampreeth Ethiraj --- .../main/java/org/opensearch/index/seqno/ReplicationTracker.java | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/main/java/org/opensearch/index/seqno/ReplicationTracker.java b/server/src/main/java/org/opensearch/index/seqno/ReplicationTracker.java index b9cb5e92d0ed1..ff91c27375788 100644 --- a/server/src/main/java/org/opensearch/index/seqno/ReplicationTracker.java +++ b/server/src/main/java/org/opensearch/index/seqno/ReplicationTracker.java @@ -1254,6 +1254,7 @@ public ReplicationCheckpoint getLatestReplicationCheckpoint() { private boolean isPrimaryRelocation(String allocationId) { Optional shardRouting = routingTable.shards() .stream() + .filter(routing -> Objects.nonNull(routing.allocationId().getId())) .filter(routing -> routing.allocationId().getId().equals(allocationId)) .findAny(); return shardRouting.isPresent() && shardRouting.get().primary();