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

[GSS](7.1.z) UNDERTOW-1418 - ServletRegistrationImpl.addMapping processing time increases with servlet counts

    XMLWordPrintable

Details

    Description

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

      Attachments

        Issue Links

          Activity

            People

              rhn-support-ivassile Ilia Vassilev
              rhn-support-ivassile Ilia Vassilev
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: