[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-4021) ArrayIndexOutOfBoundsException in SessionContext.getNames() when concurrent access from same user

Takayoshi Kimura (JIRA) jira-events at lists.jboss.org
Wed Mar 18 03:41:22 EDT 2009


ArrayIndexOutOfBoundsException in SessionContext.getNames() when concurrent access from same user
-------------------------------------------------------------------------------------------------

                 Key: JBSEAM-4021
                 URL: https://jira.jboss.org/jira/browse/JBSEAM-4021
             Project: Seam
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.1.1.GA
            Reporter: Takayoshi Kimura


ArrayIndexOutOfBoundsException in SessionContext.getNames() when concurrent access from same user

The SessionContext.getNames() calls super.getNames() and the BasicContext.getNames() does the following:

   public String[] getNames()
   {
      //yes, I know about the toArray() method,
      //but there is a bug in the RI!
      Set<String> keySet = map.keySet();
      String[] array = new String[ keySet.size() ];
      int i=0;
      for (String key: keySet)
      {
         array[i++] = key;
      }
      return array;
   }

An ArrayIndexOutOfBoundsException (and possibly a ConcurrentModificationException) could be thrown when an entry is added to the session map during iteration, after the keySet.size() call.

The FacesLifecycle uses the ExternalContext.getSessionMap() for SessionContext internal data. This map is directly tied with HttpSession and it reflects changes on the HttpSession from other threads immediately.

This problem doesn't happen with ServletLifecycle because it uses ServletRequestMap class for internal data and this class always creates new instance per keySet() call. The keySet from this map won't be changed during iteration.

This problem happends regardless of debug mode.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list