Skip to content

Commit cefd96d

Browse files
Fix NullPointerException in shard snapshot code (#111524)
Fixing a NullPointerException by instead throwing ShardNotFoundException when the IndexShard is null/gone.
1 parent 02851fc commit cefd96d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

docs/changelog/111524.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 111524
2+
summary: Fix `NullPointerException` in shard snapshot code
3+
area: Snapshot/Restore
4+
type: bug
5+
issues: []

server/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ private void snapshot(
360360
ActionListener<ShardSnapshotResult> listener
361361
) {
362362
try {
363-
final IndexShard indexShard = indicesService.indexServiceSafe(shardId.getIndex()).getShardOrNull(shardId.id());
363+
final IndexShard indexShard = indicesService.indexServiceSafe(shardId.getIndex()).getShard(shardId.id());
364364
if (indexShard.routingEntry().primary() == false) {
365365
throw new IndexShardSnapshotFailedException(shardId, "snapshot should be performed only on primary");
366366
}

0 commit comments

Comments
 (0)