From 733903f2c96f73be3d3e854b1e2fb5d3d6fe8997 Mon Sep 17 00:00:00 2001 From: orbiter Date: Mon, 3 Jan 2011 23:06:33 +0000 Subject: [PATCH] fix for http://forum.yacy-websuche.de/viewtopic.php?p=21489#p21489 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7422 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/net/yacy/kelondro/io/BufferedRecords.java | 2 +- source/net/yacy/kelondro/io/Records.java | 6 +++--- source/net/yacy/kelondro/table/Table.java | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) 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