Application Server 3  4  5 and 6
  1. Application Server 3 4 5 and 6
  2. JBAS-4075

JBossCacheManager.findLocalSessions concurrency issue

    Details

    • Type: Bug Bug
    • Status: Closed Closed (View Workflow)
    • Priority: Major Major
    • Resolution: Done
    • Affects Version/s: JBossAS-4.0.4.GA, JBossAS-4.0.5.GA, JBossAS-5.0.0.Beta1
    • Component/s: Clustering
    • Security Level: Public (Everyone can see)
    • Labels:
      None
    • Environment:
      SLES 9, SP3.
      JBOSS 4.0.5.GA
    • Similar Issues:
      Show 10 results 

      Description

      When running a load test on a JBoss Cluster I see the following exception

      2007?02?06 14:23:58,231 ERROR
      [org.jboss.web.tomcat.tc5.session.JBossCacheManager:processExpires]
      processExpires: failed with exception: java.util.NoSuchElementException
      java.util.NoSuchElementException
      at
      EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap$HashIterator.next(ConcurrentHashMap.java:1131)
      at java.util.AbstractCollection.toArray(AbstractCollection.java:176)
      at
      org.jboss.web.tomcat.tc5.session.JBossCacheManager.findLocalSessions(JBossCacheManager.java:851)
      at
      org.jboss.web.tomcat.tc5.session.JBossCacheManager.processExpires(JBossCacheManager.java:1188)
      at
      org.jboss.web.tomcat.tc5.session.JBossManager.backgroundProcess(JBossManager.java:817)
      at
      org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1284)
      at
      org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1569)
      at
      org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1578)
      at
      org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1578)
      at
      org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1558)
      at java.lang.Thread.run(Thread.java:595)

      Upon further investigation and looking at the source code of JBossCacheManager in 4.0 branch, the method findLocalSessions() suffers from concurrency issue when calling java.util.AbstractCollection.toArray(Object[] array) which is not thread safe.

        Issue Links

          Activity

          Hide
          Brian Stansberry
          added a comment -

          As Hany noted, the oswego concurrent.jar's ConcurrentHashMap's values() method returns a collection whose toArray() method isn't thread safe.

          For 4.2 and trunk I fixed this by switching to the java.util.concurrent.ConcurrentHashMap, which doesn't have this problem.

          For Branch_4_0 I copy off the collection using its thread safe iterator and then create the array from the copy.

          Show
          Brian Stansberry
          added a comment - As Hany noted, the oswego concurrent.jar's ConcurrentHashMap's values() method returns a collection whose toArray() method isn't thread safe. For 4.2 and trunk I fixed this by switching to the java.util.concurrent.ConcurrentHashMap, which doesn't have this problem. For Branch_4_0 I copy off the collection using its thread safe iterator and then create the array from the copy.
          Hide
          Brian Stansberry
          added a comment -

          Thanks for the report.

          Show
          Brian Stansberry
          added a comment - Thanks for the report.
          Hide
          Brian Stansberry
          added a comment -

          Reopening, as I see my fix for 4.2.0.CR1 wasn't correct

          Show
          Brian Stansberry
          added a comment - Reopening, as I see my fix for 4.2.0.CR1 wasn't correct

            People

            • Assignee:
              Brian Stansberry
              Reporter:
              Hany Mesha
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: