13 Replies Latest reply on Jun 22, 2006 9:27 PM by William DeCoste

    Synchronization on StatefulContainer

    Clebert Suconic Master

      Michael Yuan showed me a stack trace of some performance tests he is doing with EJB3 and Seam.

      After the test is finished, it looks like there is an infinite loop at this point:

      Several threads hanging on this point:



       at java.util.HashMap.put(HashMap.java:385)
       at org.jboss.ejb3.stateful.StatefulContainer.localInvoke
      (StatefulContainer.java:178)
       at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke
      (StatefulLocalProxy.java:98)
       at $Proxy71.getSize(Unknown Source)
       at sun.reflect.GeneratedMethodAccessor191.invoke(Unknown
      Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke
      (DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.apache.myfaces.el.PropertyResolverImpl.getProperty
      (PropertyResolverImpl.java:400)
       at org.apache.myfaces.el.PropertyResolverImpl.getValue
      (PropertyResolverImpl.java:71)
       at org.apache.myfaces.el.ELParserHelper
      $MyPropertySuffix.evaluate(ELParserHelper.java:532)
      
      



      Looking at StatefulContainer, I can see two possible mistakes:

       if (info.unadvisedMethod != null)
       {
       invokedMethod.put(id, info.unadvisedMethod);
       }
      


      I- This is leaking. unadvisedMethos is always != null, hence invokedMethod is always getting a new put

      II - This is non sycnrhonized, so I guess it makes sense the infinite loop.