Fix possible NPE in snapshot service if a shard doesn't have primary

This commit is contained in:
Igor Motov 2013-11-21 12:58:28 -05:00
parent 1d0bae0f50
commit 4ffd8a663c
1 changed files with 1 additions and 1 deletions

View File

@ -901,7 +901,7 @@ public class SnapshotsService extends AbstractComponent implements ClusterStateL
ShardRouting primary = indexRoutingTable.shard(i).primaryShard();
if (primary == null || !primary.assignedToNode()) {
//TODO: Should we bailout completely or just mark this shard as failed?
builder.put(shardId, new SnapshotMetaData.ShardSnapshotStatus(primary.currentNodeId(), State.FAILED, "primary shard is not allocated"));
builder.put(shardId, new SnapshotMetaData.ShardSnapshotStatus(null, State.FAILED, "primary shard is not allocated"));
} else if (!primary.started()) {
builder.put(shardId, new SnapshotMetaData.ShardSnapshotStatus(primary.currentNodeId(), State.FAILED, "primary shard hasn't been started yet"));
} else {