grails / grails-core

The Grails Web Application Framework
http://grails.org
Apache License 2.0
2.79k stars 950 forks source link

StandardServletMultipartResolver.resolveMultipart invoked multiple times for same request #13841

Open codeconsole opened 1 week ago

codeconsole commented 1 week ago

The following should be analyzed because off hand it seems inefficient. Multipart requests are resolved multiple times for handling url mappings which appears to be real inefficient.

https://github.com/grails/grails-core/blob/6f9d173e0af20a852971aad78a42cc42bba7fd80/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/mvc/UrlMappingsHandlerMapping.groovy#L157

https://github.com/grails/grails-core/blob/6f9d173e0af20a852971aad78a42cc42bba7fd80/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/mvc/GrailsControllerUrlMappings.java#L45-L67

https://github.com/grails/grails-core/blob/6f9d173e0af20a852971aad78a42cc42bba7fd80/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/mvc/AbstractGrailsControllerUrlMappings.groovy#L185-L203

-> DefaultUrlMappingInfo.tryMultipartParams is invoked for every UrlMappingInfo because of the call to getActionName()

https://github.com/grails/grails-core/blob/6f9d173e0af20a852971aad78a42cc42bba7fd80/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/AbstractUrlMappingInfo.java#L70-L102

https://github.com/grails/grails-core/blob/6f9d173e0af20a852971aad78a42cc42bba7fd80/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/DefaultUrlMappingInfo.java#L197-L205

due to checkDispatchAction(webRequest.getCurrentRequest());

https://github.com/grails/grails-core/blob/6f9d173e0af20a852971aad78a42cc42bba7fd80/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/DefaultUrlMappingInfo.java#L215-L221