diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShard.java b/src/main/java/org/elasticsearch/index/shard/IndexShard.java index e2ebf5579ba..71c0bc1347d 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -761,7 +761,7 @@ public class IndexShard extends AbstractIndexShardComponent { } finally { final Engine engine = this.currentEngineReference.getAndSet(null); try { - if (flushEngine && this.flushOnClose) { + if (engine != null && flushEngine && this.flushOnClose) { engine.flushAndClose(); } } finally { // playing safe here and close the engine even if the above succeeds - close can be called multiple times