Sometimes during performance test, I am seeing NPE exception in server log, thrown from UIBreadcumbsPortlet. Exception stacktrace is:
2010-10-06 09:11:15,589 ERROR [org.exoplatform.webui.application.portlet.PortletApplicationController] (http-127.0.0.1-8080-4) Error while rendering the porlet
Whole test log is attached in related issue
JBEPP-459 for completeness. It is not occuring in every performance test but only sometimes, so concurreny issue came to my mind first.
I did more investigation and I founded that the cause of problem is in thread-unsafe call of method "getUIComponentEventConfig" on class "org.exoplatform.webui.config.Component".
Problem can be seen if client1 calls this method and eventsMap is null -> eventsMap is going to initialize during this call.
But when client2 calls this method before initialization of map by client1 is finished, then problem can happen because eventsMap is not fully initialized for client2 -> client2 can't find ChangePageNode event -> listener UIPageActionListener.ChangePageNodeActionListener is not called for client2 -> UIPortal of client2 has unitialized variables selectedNode and selectedPath -> NullPointerException is thrown for client2 during rendering of BreadcumbsPortlet, because UIPortal.selectedPath is null.
Steps to reproduce (with usage of Eclispe IDE):
- Add breakpoint to class org.exoplatform.webui.config.Component to line 184 (after call of eventMap = new HashMap<String, Event>() )
- Open browser1 and go to localhost:8080/portal/public/classic . Client will be stopped on breakpoint
- Open browser2 and go to localhost:8080/portal/public/classic . This client is not seeing ChangePageNode event and so NPE is thrown for him in UIBreadcumbsPortlet.
Note: Method getUIComponentEventConfig is called many times during single HTTP request. So is it possible to fix this issue by other way that full initialization of this method? Because it can have bad impact on performance. I wonder if it's possible to initialize eventsMap in constructor of Component class (only suggestion)