[jboss-cvs] JBossAS SVN: r64767 - branches/JBoss_4_0_5_GA_CP/tomcat/src/main/org/jboss/web/tomcat/tc5/session.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 22 06:21:46 EDT 2007


Author: galder.zamarreno at jboss.com
Date: 2007-08-22 06:21:46 -0400 (Wed, 22 Aug 2007)
New Revision: 64767

Modified:
   branches/JBoss_4_0_5_GA_CP/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheManager.java
Log:
[ASPATCH-285] Port fix from 4.0.x branch

Modified: branches/JBoss_4_0_5_GA_CP/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheManager.java
===================================================================
--- branches/JBoss_4_0_5_GA_CP/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheManager.java	2007-08-22 09:43:46 UTC (rev 64766)
+++ branches/JBoss_4_0_5_GA_CP/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheManager.java	2007-08-22 10:21:46 UTC (rev 64767)
@@ -21,6 +21,7 @@
  */
 package org.jboss.web.tomcat.tc5.session;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
@@ -846,9 +847,18 @@
     */
    public ClusteredSession[] findLocalSessions()
    {
+      // JBAS-4075 -- ConcurrentHashMap.values().toArray() isn't thread
+      // safe, so we have to copy off the collection using its iterator
+      // Can't use the ArrayList c'tor or addAll, as those use toArray
+      // behind the scenes      
       Collection coll = sessions_.values();
-      ClusteredSession[] sess = new ClusteredSession[coll.size()];
-      sess = (ClusteredSession[]) coll.toArray(sess);
+      ArrayList list = new ArrayList(coll.size());
+      for (Iterator it = coll.iterator(); it.hasNext(); )
+      {
+         list.add(it.next());
+      }      
+      ClusteredSession[] sess = new ClusteredSession[list.size()];      
+      sess = (ClusteredSession[]) list.toArray(sess);
       return sess;
    }
 




More information about the jboss-cvs-commits mailing list