Skip to content

Commit 51547bf

Browse files
committed
getShardFieldStats throws AlreadyClosedException
1 parent bcc8d26 commit 51547bf

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

server/src/main/java/org/elasticsearch/index/engine/Engine.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,12 @@ protected final DocsStats docsStats(IndexReader indexReader) {
245245
return new DocsStats(numDocs, numDeletedDocs, sizeInBytes);
246246
}
247247

248+
/**
249+
* @throws AlreadyClosedException if the shard is closed
250+
*/
248251
public ShardFieldStats getShardFieldStats() {
249252
try (var searcher = acquireSearcher("shard_field_stats", Engine.SearcherScope.INTERNAL)) {
250253
return getShardFieldStats(searcher.getLeafContexts());
251-
} catch (AlreadyClosedException ignored) {
252-
return null;
253254
}
254255
}
255256

server/src/main/java/org/elasticsearch/index/shard/IndexShard.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4140,7 +4140,9 @@ public void beforeRefresh() {
41404140
@Override
41414141
public void afterRefresh(boolean didRefresh) {
41424142
if (shardFieldStats == null || didRefresh) {
4143-
shardFieldStats = getEngine().getShardFieldStats();
4143+
try {
4144+
shardFieldStats = getEngine().getShardFieldStats();
4145+
} catch (AlreadyClosedException ignored) {}
41444146
}
41454147
}
41464148
}

0 commit comments

Comments
 (0)