Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
fixed some critical errors in kelondro
Michael Peter Christen05d0f6804032
diff --git a/source/net/yacy/kelondro/blob/BEncodedHeap.java b/source/net/yacy/kelondro/blob/BEncodedHeap.javaindex 60cec4dce..5c1669a85 100644--- a/source/net/yacy/kelondro/blob/BEncodedHeap.java+++ b/source/net/yacy/kelondro/blob/BEncodedHeap.java@@ -321,6 +321,7 @@ public class BEncodedHeap implements MapStore {return null;}final Map<String, byte[]> map = b2m(b);+ if (map == null) return null;return map.get(key);}diff --git a/source/net/yacy/kelondro/data/word/WordReferenceFactory.java b/source/net/yacy/kelondro/data/word/WordReferenceFactory.javaindex a7db4c03a..bb8223e09 100644--- a/source/net/yacy/kelondro/data/word/WordReferenceFactory.java+++ b/source/net/yacy/kelondro/data/word/WordReferenceFactory.java@@ -123,7 +123,7 @@ public class WordReferenceFactory implements ReferenceFactory<WordReference>, Sepublic static final SortedMap<String, Set<String>> decompressIndex(ByteBuffer ci, final String peerhash) {SortedMap<String, Set<String>> target = Collections.synchronizedSortedMap(new TreeMap<String, Set<String>>());// target is a mapping from url-hashes to a string of peer-hashes- if (ci.byteAt(0) != '{' || ci.byteAt(ci.length() - 1) != '}') return target;+ if (ci.isEmpty() || ci.byteAt(0) != '{' || ci.byteAt(ci.length() - 1) != '}') return target;//System.out.println("DEBUG-DECOMPRESS: input is " + ci.toString());ci = ci.trim(1, ci.length() - 2);String dom, url;diff --git a/source/net/yacy/kelondro/index/OnDemandOpenFileIndex.java b/source/net/yacy/kelondro/index/OnDemandOpenFileIndex.javaindex 9ea6b1abd..7be27b7cb 100644--- a/source/net/yacy/kelondro/index/OnDemandOpenFileIndex.java+++ b/source/net/yacy/kelondro/index/OnDemandOpenFileIndex.java@@ -122,8 +122,8 @@ public class OnDemandOpenFileIndex implements Index, Iterable<Row.Entry> {final Index index = this.getIndex();if (index == null) return;try {- index.clear();- this.sizecache = 0;+ index.clear();+ this.sizecache = 0;} catch (final IOException e) {throw e;} finally {@@ -139,6 +139,7 @@ public class OnDemandOpenFileIndex implements Index, Iterable<Row.Entry> {@Overridepublic synchronized void deleteOnExit() {final Index index = this.getIndex();+ if (index == null) return;index.deleteOnExit();index.close();}diff --git a/source/net/yacy/kelondro/index/RAMIndex.java b/source/net/yacy/kelondro/index/RAMIndex.javaindex 0913d87e1..8009edf49 100644--- a/source/net/yacy/kelondro/index/RAMIndex.java+++ b/source/net/yacy/kelondro/index/RAMIndex.java@@ -120,7 +120,7 @@ public final class RAMIndex implements Index, Iterable<Row.Entry> {final byte[] b0 = this.index0.smallestKey();if (b0 == null) return null;if (this.index1 == null) return b0;- final byte[] b1 = this.index0.smallestKey();+ final byte[] b1 = this.index1.smallestKey();if (b1 == null || this.rowdef.objectOrder.compare(b1, b0) > 0) return b0;return b1;}@@ -130,7 +130,7 @@ public final class RAMIndex implements Index, Iterable<Row.Entry> {final byte[] b0 = this.index0.largestKey();if (b0 == null) return null;if (this.index1 == null) return b0;- final byte[] b1 = this.index0.largestKey();+ final byte[] b1 = this.index1.largestKey();if (b1 == null || this.rowdef.objectOrder.compare(b0, b1) > 0) return b0;return b1;}diff --git a/source/net/yacy/kelondro/logging/GuiHandler.java b/source/net/yacy/kelondro/logging/GuiHandler.javaindex 69119cdc6..c1366e31d 100644--- a/source/net/yacy/kelondro/logging/GuiHandler.java+++ b/source/net/yacy/kelondro/logging/GuiHandler.java@@ -90,7 +90,7 @@ public class GuiHandler extends Handler {}@Override- public final void publish(final LogRecord record) {+ public final synchronized void publish(final LogRecord record) {if (!this.isLoggable(record)) return;final int ix = (GuiHandler.start + GuiHandler.count) % GuiHandler.buffer.length;GuiHandler.buffer[ix] = this.getFormatter().format(record);diff --git a/source/net/yacy/kelondro/table/Relations.java b/source/net/yacy/kelondro/table/Relations.javaindex da2116c48..f91e2b7b7 100644--- a/source/net/yacy/kelondro/table/Relations.java+++ b/source/net/yacy/kelondro/table/Relations.java@@ -51,6 +51,7 @@ public class Relations {final boolean useTailCache,final boolean exceed134217727) {this.baseDir = location;+ this.relations = new HashMap<>();this.useTailCache = useTailCache;this.exceed134217727 = exceed134217727;}@@ -86,7 +87,7 @@ public class Relations {final Index relation = this.relations.get(name);if (relation != null) return;// try to find the relation as stored on file- final String[] list = this.baseDir.list();+ final String[] list = this.baseDir.exists() && this.baseDir.isDirectory() ? this.baseDir.list() : new String[0];final String targetfilename = filename(name, keysize, payloadsize);for (int i = 0; i < list.length; i++) {if (list[i].startsWith(name)) {diff --git a/source/net/yacy/kelondro/workflow/WorkflowProcessor.java b/source/net/yacy/kelondro/workflow/WorkflowProcessor.javaindex 95915993d..b1bdf0bef 100644--- a/source/net/yacy/kelondro/workflow/WorkflowProcessor.java+++ b/source/net/yacy/kelondro/workflow/WorkflowProcessor.java@@ -180,7 +180,8 @@ public class WorkflowProcessor<J extends WorkflowJob> {return;}// execute concurrent in thread- while (this.input != null) {+ int failcount = 0; // to prevent endless loops+ while (this.input != null && failcount < 10) {try {this.input.put(in);if (this.input.size() > this.executorRunning.get() && this.executorRunning.get() < this.maxpoolsize) synchronized (executor) {@@ -191,6 +192,8 @@ public class WorkflowProcessor<J extends WorkflowJob> {}break;} catch (final Throwable e) {+ failcount++;+ ConcurrentLog.logException(e);try {Thread.sleep(10);} catch (final InterruptedException ee) {}}}