Protect against the leader index being removed
when dealing with TimeoutException
The `IndexFollowingIT#testDeleteLeaderIndex()`` test failed,
because a NPE was captured as fatal error instead of an IndexNotFoundException.
Closes
@@ -27,6 +27,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.engine.MissingHistoryOperationsException;
@@ -434,6 +435,11 @@ public class ShardChangesAction extends Action<ShardChangesAction.Request, Shard
if (e instanceof TimeoutException) {
try {
final IndexMetaData indexMetaData = clusterService.state().metaData().index(shardId.getIndex());
+ if (indexMetaData == null) {
+ listener.onFailure(new IndexNotFoundException(shardId.getIndex()));
+ return;
+ }
+
final long mappingVersion = indexMetaData.getMappingVersion();
final long settingsVersion = indexMetaData.getSettingsVersion();
final SeqNoStats latestSeqNoStats = indexShard.seqNoStats();
