diff --git a/src/main/java/org/elasticsearch/index/translog/fs/FsTranslog.java b/src/main/java/org/elasticsearch/index/translog/fs/FsTranslog.java index 178aef4ba7f..2c316ac8bbe 100644 --- a/src/main/java/org/elasticsearch/index/translog/fs/FsTranslog.java +++ b/src/main/java/org/elasticsearch/index/translog/fs/FsTranslog.java @@ -291,15 +291,19 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog @Override public void revertTransient() { - FsTranslogFile old; + FsTranslogFile tmpTransient; rwl.writeLock().lock(); try { - old = trans; + tmpTransient = trans; this.trans = null; } finally { rwl.writeLock().unlock(); } - old.close(true); + // previous transient might be null because it was failed on its creation + // for example + if (tmpTransient != null) { + tmpTransient.close(true); + } } public byte[] read(Location location) {