From ed01d535065b4104bc54f3aa64459ade56475668 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Sat, 30 Nov 2013 00:30:21 +0100 Subject: [PATCH] NullPointerException in FsTranslog when reverting transient log This happens when reverting the trans transaction log on failure, and when that happens, actually we might have failed on the transient translog creation to being with.... fixes #4223 --- .../elasticsearch/index/translog/fs/FsTranslog.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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) {