From ef7fe537c52f0ff84468f94e484a0e0be00b9684 Mon Sep 17 00:00:00 2001 From: orbiter Date: Tue, 6 Jan 2009 10:51:56 +0000 Subject: [PATCH] fixed a cache-bug in cachedFileRA git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5445 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/kelondro/kelondroCachedFileRA.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/de/anomic/kelondro/kelondroCachedFileRA.java b/source/de/anomic/kelondro/kelondroCachedFileRA.java index 0df0b8c32..8f9c6c8dd 100644 --- a/source/de/anomic/kelondro/kelondroCachedFileRA.java +++ b/source/de/anomic/kelondro/kelondroCachedFileRA.java @@ -94,7 +94,13 @@ public final class kelondroCachedFileRA extends kelondroAbstractRA implements ke public synchronized void write(final byte[] b, final int off, final int len) throws IOException { //assert len > 0; // write to file - if (this.cache.length > 512) this.cache = new byte[512]; // the large cache is only useful during an initialization phase + if (this.cache.length > 512) { + // the large cache is only useful during an initialization phase + byte[] newcache = new byte[512]; + System.arraycopy(this.cache, 0, newcache, 0, newcache.length); + this.cache = newcache; + if (this.cachelen > this.cache.length) this.cachelen = this.cache.length; + } long seekpos = this.RAFile.getFilePointer(); if (this.cachelen + len <= this.cache.length && this.cachestart + this.cachelen == seekpos) { // append to cache