activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <>
Subject thread safety problem in ServerSessionPoolImpl.getServerSession()?
Date Fri, 14 Mar 2008 06:49:41 GMT
While fixing 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?

david jencks

View raw message