diff --git a/source/de/anomic/kelondro/kelondroStack.java b/source/de/anomic/kelondro/kelondroStack.java index 76ca8bf0f..8a9f0c41d 100644 --- a/source/de/anomic/kelondro/kelondroStack.java +++ b/source/de/anomic/kelondro/kelondroStack.java @@ -292,7 +292,7 @@ public final class kelondroStack extends kelondroRecords { Handle h = getHandle(side); if (h == null) return null; if (dist >= size()) return null; // that would exceed the stack - while (dist-- > 0) h = getNode(h, false).getOHHandle(dir); // track through elements + while ((dist-- > 0) && (h != null)) h = getNode(h, false).getOHHandle(dir); // track through elements if (h == null) return null; else return getNode(h, true); } diff --git a/source/de/anomic/yacy/yacyNewsPool.java b/source/de/anomic/yacy/yacyNewsPool.java index 1c2655e0e..68b6f6dfe 100644 --- a/source/de/anomic/yacy/yacyNewsPool.java +++ b/source/de/anomic/yacy/yacyNewsPool.java @@ -402,30 +402,13 @@ public class yacyNewsPool { return false; } - /* - public yacyNewsRecord get(int dbKey, int element) throws IOException { - yacyNewsQueue queue = switchQueue(dbKey); - yacyNewsRecord record = null; - int s; - synchronized (queue) { - while ((record == null) && ((s = queue.size()) > 0)) { - record = queue.top(element); - if (record == null) { - queue.pop(element); - if (queue.size() == s) break; - } - } - } - return record; - } - */ - public synchronized yacyNewsRecord getSpecific(int dbKey, String category, String key, String value) throws IOException { yacyNewsQueue queue = switchQueue(dbKey); yacyNewsRecord record; String s; - for (int i = queue.size() - 1; i >= 0; i--) { - record = queue.top(i); + Iterator i = queue.records(true); + while (i.hasNext()) { + record = (yacyNewsRecord) i.next(); if ((record != null) && (record.category().equals(category))) { s = (String) record.attributes().get(key); if ((s != null) && (s.equals(value))) return record; diff --git a/source/de/anomic/yacy/yacyNewsQueue.java b/source/de/anomic/yacy/yacyNewsQueue.java index 16d1b7da0..b35c29707 100644 --- a/source/de/anomic/yacy/yacyNewsQueue.java +++ b/source/de/anomic/yacy/yacyNewsQueue.java @@ -164,6 +164,7 @@ public class yacyNewsQueue { } public Iterator records(boolean up) { + // iterates yacyNewsRecord-type objects return new newsIterator(up); }