Description
Changes made via QPID-4760 exposed a defect in ConnectionAdapter.getSessions() which can cause a ConcurrentModificationException. This is due to unsafe use of map.remove() whilst iterating the map keyset. The code will be change to use an Iterator and call iterator.remove instead.
Recent test failure stacktrace showing the issue:
IoReceiver - /127.0.0.1:60051 2013-04-26 15:25:31,050 ERROR [qpid.server.transport.ServerSessionDelegate] Exception processing command java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:806) at java.util.HashMap$KeyIterator.next(HashMap.java:841) at org.apache.qpid.server.model.adapter.ConnectionAdapter.getSessions(ConnectionAdapter.java:67) at org.apache.qpid.server.model.adapter.ConnectionAdapter.getSessionAdapter(ConnectionAdapter.java:97) at org.apache.qpid.server.model.adapter.QueueAdapter.getSessionAdapter(QueueAdapter.java:118) at org.apache.qpid.server.model.adapter.QueueAdapter.subscriptionRegistered(QueueAdapter.java:616) at org.apache.qpid.server.queue.SimpleAMQQueue.registerSubscription(SimpleAMQQueue.java:447) at org.apache.qpid.server.transport.ServerSessionDelegate.messageSubscribe(ServerSessionDelegate.java:266) at org.apache.qpid.server.transport.ServerSessionDelegate.messageSubscribe(ServerSessionDelegate.java:73)