Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-15583

[GSS](7.2.z) ServletRegistrationImpl.addMapping processing time increases with servlet counts

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 7.2.0.GA
    • 7.2.0.CD14
    • Undertow
    • None

      io.undertow.servlet.spec.ServletRegistrationImpl.addMapping is O( n ) for the number of servlets as it iterates through the full list of them to be able to check all their mappings:

          public Set<String> addMapping(final String... urlPatterns) {
              DeploymentInfo deploymentInfo = deployment.getDeploymentInfo();
              final Set<String> ret = new HashSet<>();
              final Set<String> existing = new HashSet<>();
              for (ServletInfo s : deploymentInfo.getServlets().values()) {
                  if (!s.getName().equals(servletInfo.getName())) {
                      existing.addAll(s.getMappings());
                  }
              }
              for (String pattern : urlPatterns) {
                  if (existing.contains(pattern)) {
                      ret.add(pattern);
                  }
      }
      

      Compared to StandardWrapperFacade.addMapping in JBossWeb Tomcat, which just checks the given urlPatterns against a maintained map of existing pattern/name pairs, this does not perform or scale as well with high servlet/jsp counts (thousands):

          public Set<String> addMapping(String... urlPatterns) {
              Set<String> conflicts = new HashSet<String>();
              if (!((Context) wrapper.getParent()).isStarting()) {
                  throw MESSAGES.cannotAddServletRegistrationAfterInit(((Context) wrapper.getParent()).getPath());
              }
              if (urlPatterns == null || urlPatterns.length == 0) {
                  throw MESSAGES.invalidServletRegistrationArguments();
              }
              for (String urlPattern : urlPatterns) {
      			Context context = ((Context) wrapper.getParent());
                  String wrapperName = context.findServletMapping(urlPattern);
                  if (wrapperName != null) {
                      Wrapper servletWrapper = (Wrapper) context.findChild(wrapperName);
                      if (servletWrapper.isOverridable()) {
                          // Some Wrappers (from global and host web.xml) may be
                          // overridden rather than generating a conflict
                          context.removeServletMapping(urlPattern);
                      } else {
                          conflicts.add(urlPattern);
                      }
      			}
              }
      

              rhn-support-ivassile Ilia Vassilev
              rhn-support-aogburn Aaron Ogburn
              Jan Stourac Jan Stourac
              Jan Stourac Jan Stourac
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: