Affects: 5.3.8


the code fragment below in method getHandlerMapping, line 168

    Map<String, HttpRequestHandler> urlMap = new LinkedHashMap<>();
    for (ResourceHandlerRegistration registration : this.registrations) {
    for (String pathPattern : registration.getPathPatterns()) {

            // 1. we get the 'handler' here from the outer loop variable 'registration', 
            //    set it's properties all with bean fields
            ResourceHttpRequestHandler handler = registration.getRequestHandler();
            if (this.pathHelper != null) {
          handler.setUrlPathHelper(this.pathHelper);
            }
            if (this.contentNegotiationManager != null) {
          handler.setContentNegotiationManager(this.contentNegotiationManager);
            }
            handler.setServletContext(this.servletContext);
            handler.setApplicationContext(this.applicationContext);
            try {
          handler.afterPropertiesSet();
            }
            catch (Throwable ex) {
          throw new BeanInitializationException("Failed to init ResourceHttpRequestHandler", ex);
            }

            // 2.  and here, we put it in a map, with inner loop's element as the key
            urlMap.put(pathPattern, handler);
    }
    }

Can't we move the code fragment in the inner loop between comment 1 and 2 to the outer loop?

Comment From: rstoyanchev

Good point. It looks like the inner loop grew over time and it went unnoticed.