From b6e2c4a3c2aefc77022d4db4698b667c27d4d6a3 Mon Sep 17 00:00:00 2001 From: Sagar Upadhyaya Date: Wed, 10 Jan 2024 15:32:43 -0800 Subject: [PATCH] Changing logic to fetch Index shard from shardId Signed-off-by: Sagar Upadhyaya --- .../main/java/org/opensearch/indices/IndicesService.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/opensearch/indices/IndicesService.java b/server/src/main/java/org/opensearch/indices/IndicesService.java index 2cab59b14dd8e..db5b93f073b03 100644 --- a/server/src/main/java/org/opensearch/indices/IndicesService.java +++ b/server/src/main/java/org/opensearch/indices/IndicesService.java @@ -410,10 +410,8 @@ public IndicesService( this.analysisRegistry = analysisRegistry; this.indexNameExpressionResolver = indexNameExpressionResolver; this.indicesRequestCache = new IndicesRequestCache(settings, (shardId -> { - IndexService indexService = null; - try { - indexService = indexServiceSafe(shardId.getIndex()); - } catch (IndexNotFoundException ex) { + IndexService indexService = this.indices.get(shardId.getIndex().getUUID()); + if (indexService == null) { return Optional.empty(); } return Optional.of(new IndexShardCacheEntity(indexService.getShard(shardId.id())));