While fixing https://issues.apache.org/activemq/browse/AMQ-1618 I noticed that although there are some half-hearted attempts to look like there's thread safety in this method (use of CopyOnWriteArrayList) actually its completely unsafe.

For instance

        if (idleSessions.size() > 0) {
ServerSessionImpl ss = idleSessions.remove (idleSessions.size() - 1);

executed by 2 threads can easily result in one getting an index out of bounds error or one trying to remove a server session from an empty list.

Before I look at fixing it could anyone confirm that in fact this method should be thread safe?

thanks
david jencks

Reply via email to