[gatein-issues] [JBoss JIRA] Created: (GTNPORTAL-1545) Concurrency problem (HashMap used in class ConfigurationManager in multithreaded environment)

Marek Posolda (JIRA) jira-events at lists.jboss.org
Thu Oct 7 04:24:39 EDT 2010


Concurrency problem (HashMap used in class ConfigurationManager in multithreaded environment)
---------------------------------------------------------------------------------------------

                 Key: GTNPORTAL-1545
                 URL: https://jira.jboss.org/browse/GTNPORTAL-1545
             Project: GateIn Portal
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: WebUI
    Affects Versions: 3.1.0-GA
         Environment: GateIn trunk (revision 4282) on EAP5
            Reporter: Marek Posolda
         Attachments: exception-stacktrace.txt

Sometimes I can see exception during startup of performance. Exception is something like: 

java.lang.reflect.InvocationTargetException: ...
Caused by: java.lang.Exception: Cannot find the configuration for the component org.exoplatform.portal.webui.container.UIContainerList, configId null
	at org.exoplatform.webui.application.WebuiApplication.createUIComponent(WebuiApplication.java:110)
	at org.exoplatform.webui.core.UIContainer.addChild(UIContainer.java:197)
	at org.exoplatform.portal.webui.portal.UIPortalComposer.<init>(UIPortalComposer.java:97)
	... 71 more

Whole stacktrace is attached. I am not seeing it in every test run, only sometimes. And usually the component is different in each case (sometimes it fails with different component that UIContainerList). 

After investigation, I founded that problem is in class org.exoplatform.webui.application.ConfigurationManager which is shared by more clients (threads) but it's using HashMap "configs_". This piece of code in ConfigurationManager.getComponentConfig(Class<?> type, String id)

      //
      Component config = configs_.get(key);
      if (config != null)
      {
         return config;
      }
      //
      process(type);
      //
      return configs_.get(key);

is read component configuration (in case that this configuration is missing in map) and then it saves into HashMap and returns it. But in multithreaded environment, sometimes can still happen that this method returns null because "config_" HashMap is not thread-safe -> Exception is thrown in WebuiApplication.createUIComponent(WebuiApplication.java:110).

See this article http://java.dzone.com/articles/concurrency-and-hashmap with nice simple example, which is doing very similar scenario as ConfigurationManager.

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

        


More information about the gatein-issues mailing list