From 090c73e32e65a7bcaddab1bacf87fa0d7e29fd8f Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 12 Jan 2011 12:04:18 +0000 Subject: [PATCH] catch a OOM in HeapReader iteration git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7433 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/net/yacy/kelondro/blob/HeapReader.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source/net/yacy/kelondro/blob/HeapReader.java b/source/net/yacy/kelondro/blob/HeapReader.java index d95404dfa..22f8449a0 100644 --- a/source/net/yacy/kelondro/blob/HeapReader.java +++ b/source/net/yacy/kelondro/blob/HeapReader.java @@ -639,9 +639,17 @@ public class HeapReader { // so far we have read this.keylen - 1 + 1 = this.keylen bytes. // there must be a remaining number of len - this.keylen bytes left for the BLOB if (len < this.keylen) return null; // a strange case that can only happen in case of corrupted data - payload = new byte[len - this.keylen]; // the remaining record entries - if (is.read(payload) < payload.length) return null; - return new entry(key, payload); + try { + payload = new byte[len - this.keylen]; // the remaining record entries + if (is.read(payload) < payload.length) return null; + return new entry(key, payload); + } catch (OutOfMemoryError e) { + // the allocation of memory for the payload may fail + // this is bad because we must interrupt the iteration here but the + // process that uses the iteration may think that the iteraton has just been completed + Log.logSevere("HeapReader", "out of memory in LookAheadIterator.next0", e); + return null; + } } } catch (final IOException e) { return null;