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
This commit is contained in:
Shay Banon 2013-11-30 00:30:21 +01:00
parent fe1d22af01
commit ed01d53506
1 changed files with 7 additions and 3 deletions

View File

@ -291,15 +291,19 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog
@Override @Override
public void revertTransient() { public void revertTransient() {
FsTranslogFile old; FsTranslogFile tmpTransient;
rwl.writeLock().lock(); rwl.writeLock().lock();
try { try {
old = trans; tmpTransient = trans;
this.trans = null; this.trans = null;
} finally { } finally {
rwl.writeLock().unlock(); 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) { public byte[] read(Location location) {