diff --git a/source/de/anomic/yacy/yacyNewsPool.java b/source/de/anomic/yacy/yacyNewsPool.java index f454ec16b..9daead131 100644 --- a/source/de/anomic/yacy/yacyNewsPool.java +++ b/source/de/anomic/yacy/yacyNewsPool.java @@ -265,20 +265,10 @@ public class yacyNewsPool { private boolean moveOff(yacyNewsQueue fromqueue, yacyNewsQueue toqueue, String id) throws IOException { // called if a published news shall be removed - // the news is also removed from the news database - yacyNewsRecord record; - synchronized (fromqueue) { - while (fromqueue.size() > 0) { - record = fromqueue.top(0); - if ((record != null) && (record.id().equals(id))) { - fromqueue.pop(0); - if (toqueue != null) toqueue.push(record); - //newsDB.remove(id); - return true; - } - } - } - return false; + yacyNewsRecord record = fromqueue.remove(id); + if (record == null) return false; + toqueue.push(record); + return true; } diff --git a/source/de/anomic/yacy/yacyNewsQueue.java b/source/de/anomic/yacy/yacyNewsQueue.java index 92765ee49..a1d141cca 100644 --- a/source/de/anomic/yacy/yacyNewsQueue.java +++ b/source/de/anomic/yacy/yacyNewsQueue.java @@ -129,6 +129,19 @@ public class yacyNewsQueue { return entry; } + public synchronized yacyNewsRecord remove(String id) throws IOException { + yacyNewsRecord record; + for (int i = 0; i < size(); i++) { + record = top(i); + if ((record != null) && (record.id().equals(id))) { + pop(i); + return record; + } + } + return null; + } + + /* public synchronized void incDistributedCounter(yacyNewsRecord entry) throws IOException { // this works only if the entry element lies ontop of the stack