Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.kaazing.net.impl.util.BlockingQueueImpl : take() and put() can miss done() or reset() and remain blocking #43

Open
giltene opened this issue Jan 9, 2021 · 0 comments

Comments

@giltene
Copy link

giltene commented Jan 9, 2021

I happened to run across this in code inspection (actually just searching GitHub for occurrences of notifyAll()) to see if I can spot bugs around them in a few minutes, as part of some other silly exercise), so I figured I’d point it out here in case it matters.

The (sole?) purpose of org.kaazing.net.impl.util.BlockingQueueImpl appears to be to add interrupt and end of stream capability to j.u.c.ArrayBlockingQueue. However, in the implementation, a done() or reset() call may leave threads blocked on a take() or put() until actual contents is added or removed to/from the queue. For example, if done() or reset() are executed right before a thread executes this line of code (but after that thread entered the take() method), the notifyAll() calls in done() or reset(), and the done indication, will have no effect and the thread can remain blocked until further contents arrives on the queue.

A similar situation can happen in the put() implementation here.

@giltene giltene changed the title org.kaazing.net.impl.util.BlockingQueueImpl : take() and put() can miss done() or clear() and remain blocking org.kaazing.net.impl.util.BlockingQueueImpl : take() and put() can miss done() or reset() and remain blocking Jan 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant