Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-3310

NavigationHandler initialization is not thread-safe

    XMLWordPrintable

    Details

      Description

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

      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:]
      

      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:

          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);
              }
          }
      

      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().

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              fjuma Farah Juma
              Reporter:
              hwellmann.de Harald Wellmann (Inactive)
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: