ISPN-4626 Race condition in the LocalEntryRetriever between iterator() a...

...nd hasNext()

https://issues.jboss.org/browse/ISPN-4626
What is the exact case here?  I think we are adding a lot of extra contention by always aquiring the lock.  I think what was happening is the following which is different than what you stated.

thread 1 sees nothing in queue so hasNext was false
thread 1 is put to sleep
thread 2 adds values and then completes the iterator
thread 1 wakes up and sees completed as true
thread 1 then evaluates this if block and finds no changes.

I am thinking all the change that is required is to remove && !completed.  So this way it would force a recheck of the queue.