Skip to content

Commit 8ceaf80

Browse files
committed
Check engine reference for null before flushing
If we close the shard before the engine is started we see a NPE in the logs which is not problematic since the relevant parts are in a finally block. Yet, the NPE is unnecessary and can be confusing.
1 parent bef2153 commit 8ceaf80

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ public void close(String reason, boolean flushEngine) throws IOException {
756756
} finally {
757757
final Engine engine = this.currentEngineReference.getAndSet(null);
758758
try {
759-
if (flushEngine && this.flushOnClose) {
759+
if (engine != null && flushEngine && this.flushOnClose) {
760760
engine.flushAndClose();
761761
}
762762
} finally {

0 commit comments

Comments
 (0)