Skip to content

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

Open
@giltene

Description

@giltene

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions