CDV ❯ improper locking in LinkedBlockingQueue.poll()
-
Bug
-
Status: Open
-
2 Major
-
Resolution:
-
Byte Code Transform
-
-
cdennis
-
Reporter: teck
-
May 12, 2009
-
0
-
Watchers: 0
-
October 11, 2011
-
Description
There is no common lock (with respect to put/offer) when an LBQ is empty. It is possible to get an invalid NoSuchElementException from remove() (which is based on poll()) in this case (see DEV-2797). The AtomicInteger inside of LBQ is relevant to behavior of LBQ in this regard but this counter is not clustered – as such you can get back null from poll() since you can race with receiving a broadcast of the put/offer.
The caution here is that naive clustering of that internal counter will probably greater affect (negatively) the effectiev concurrency of an LBQ in the cluster.
Can we add the workaround to comments?