security patch for WeakPriorityBlockingQueue (produced a deadlock)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7307 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent 5dcb838293
commit 441fbc26e2

@ -198,7 +198,15 @@ public class WeakPriorityBlockingQueue<E> {
}
synchronized (this) {
if (position >= this.queue.size() + this.drained.size()) return null; // we don't have that element
while (position >= this.drained.size()) this.poll();
Element<E> p;
int s;
while (position >= this.drained.size()) {
s = this.drained.size();
p = this.poll();
if (this.drained.size() <= s) break;
if (p == null) break;
}
if (position >= this.drained.size()) return null;
return this.drained.get(position);
}
}

Loading…
Cancel
Save