ServletRequestDataBinder assumes Standard servlet multipart handling #26999
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: regression
A bug that is also a regression
Milestone
Affects: Spring Framework (spring-web) 5.3.7
In our project we have one controller which needs to handle very large file uploads using a streaming solution similar to this post.
However, since Spring Framework 5.3 (d61c0ee), the
ServletRequestDataBinder
, when it sees a "multipart/" content type which is not handled by aMultipartResolver
yet it tries to resolve it itself by callingStandardServletPartUtils.bindParts(...)
, which in turn callsHttpServletRequest.getParts()
which throws an exception because multipart is not configured on servlet level.Switching to standard servlet multipart wouldn't help in this case, because that would make the request non-streaming.
I'm not entirely sure what a good solution would be, since as far as I know you can't really ask the servlet whether multipart is configured, and
HttpServletRequest.getParts()
throwing anIllegalStateException
could also be due to exceeding file limitations. Maybe some addition to theMultipartResolver
interface, or something inWebMvcConfigurationSupport
to configure it?Extra context
Some extra context, in case it matters: we are using the
CommonsMultipartResolver
because we have many controllers which need to handle normal file uploads. For the very large file upload we use a PUT request instead of POST, becauseCommonsMultipartResolver.isMultipart(...)
only returnstrue
for POST requests, so it doesn't try to process the multipart request yet in theDispatcherServlet
.We use multipart instead of just using the file itself as the body, because we also need to include some other information which might not fit the url query parameters.
The
ServletRequestDataBinder
gets triggered (I think) because we also include a model object as a method parameter which gets filled from url query parameters and gets validated. If you want I can include an example of the controller method.The text was updated successfully, but these errors were encountered: