[jboss-jira] [JBoss JIRA] (WFLY-3310) NavigationHandler initialization is not thread-safe

Harald Wellmann (JIRA) issues at jboss.org
Fri May 2 04:03:56 EDT 2014


Harald Wellmann created WFLY-3310:
-------------------------------------

             Summary: NavigationHandler initialization is not thread-safe
                 Key: WFLY-3310
                 URL: https://issues.jboss.org/browse/WFLY-3310
             Project: WildFly
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: JSF
    Affects Versions: 8.0.0.Final
         Environment: Ubuntu 14.04, Oracle JDK 1.8.0_05
            Reporter: Harald Wellmann
            Assignee: Farah Juma


Running a stress test on my application with a large number of concurrent clients, I'm getting the following exception:

{noformat}
Caused by: java.lang.NullPointerException
	at com.sun.faces.application.NavigationHandlerImpl$NavigationInfo.access$000(NavigationHandlerImpl.java:1364) [jsf-impl-2.2.5-jbossorg-3.jar:]
	at com.sun.faces.application.NavigationHandlerImpl.getNavigationMap(NavigationHandlerImpl.java:296) [jsf-impl-2.2.5-jbossorg-3.jar:]
	at com.sun.faces.application.NavigationHandlerImpl.getViewId(NavigationHandlerImpl.java:478) [jsf-impl-2.2.5-jbossorg-3.jar:]
	at com.sun.faces.application.NavigationHandlerImpl.getNavigationCase(NavigationHandlerImpl.java:149) [jsf-impl-2.2.5-jbossorg-3.jar:]
	at com.sun.faces.application.NavigationHandlerImpl.getNavigationCase(NavigationHandlerImpl.java:140) [jsf-impl-2.2.5-jbossorg-3.jar:]
{noformat}

This exception no longer occurs when the application has been warmed up by running a single request before going parallel.

The root cause appears to be in {{com.sun.faces.application.NavigationHandlerImpl}}:

{code}
    private void createNavigationMaps() {
        if (null == navigationMaps) {
            NavigationMap result = null;
            NavigationInfo info = null;
            navigationMaps = new ConcurrentHashMap<String, NavigationInfo>();
            result = new NavigationMap();
            info = new NavigationInfo();
            info.ruleSet = result;
            navigationMaps.put(ROOT_NAVIGATION_MAP_ID, info);
        }
    }
{code}

The member {{this.navigationMaps}} is set *before* {{ROOT_NAVIGATION_MAP_ID}} is put into the map, so another thread may get null from {{navigationMap.get(ROOT_NAVIGATION_MAP_ID)}} in method {{getNavigationMap()}}.



--
This message was sent by Atlassian JIRA
(v6.2.3#6260)


More information about the jboss-jira mailing list