diff --git a/source/net/yacy/kelondro/io/BufferedRecords.java b/source/net/yacy/kelondro/io/BufferedRecords.java index 8e7b0f163..529a0697a 100644 --- a/source/net/yacy/kelondro/io/BufferedRecords.java +++ b/source/net/yacy/kelondro/io/BufferedRecords.java @@ -59,7 +59,7 @@ public final class BufferedRecords { */ public synchronized void flushBuffer() throws IOException { this.flushBuffer0(); - efs.flushBuffer(); + if (efs != null) efs.flushBuffer(); } private final void flushBuffer0() throws IOException { diff --git a/source/net/yacy/kelondro/io/Records.java b/source/net/yacy/kelondro/io/Records.java index 493580193..96ae05dac 100644 --- a/source/net/yacy/kelondro/io/Records.java +++ b/source/net/yacy/kelondro/io/Records.java @@ -178,6 +178,7 @@ public final class Records { * write buffer to end of file */ protected final synchronized void flushBuffer() { + if (raf == null) return; try { raf.seek(raf.length()); raf.write(this.buffer, 0, this.recordsize * this.buffercount); @@ -188,10 +189,9 @@ public final class Records { } public final synchronized void close() { - flushBuffer(); - - // then close the file + // close the file if (raf != null) try { + flushBuffer(); raf.close(); } catch (final IOException e) { Log.logException(e); diff --git a/source/net/yacy/kelondro/table/Table.java b/source/net/yacy/kelondro/table/Table.java index ae49b229f..23f433a52 100644 --- a/source/net/yacy/kelondro/table/Table.java +++ b/source/net/yacy/kelondro/table/Table.java @@ -430,7 +430,7 @@ public class Table implements Index, Iterable { } public void close() { - this.file.close(); + if (this.file != null) this.file.close(); this.file = null; if (this.table != null) this.table.close(); this.table = null; @@ -778,7 +778,8 @@ public class Table implements Index, Iterable { public synchronized void clear() throws IOException { final File f = file.filename(); - file.close(); + this.file.close(); + this.file = null; FileUtils.deletedelete(f); // make new file