Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StandardServletMultipartResolver should support MaxUploadSizeExceededException against common servers [SPR-9294] #13932

Closed
spring-projects-issues opened this issue Apr 1, 2012 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Apr 1, 2012

Marten Deinum opened SPR-9294 and commented

Currently all exceptions thrown by the standard multipart support lead to the generic MultipartException. It would be nice if, like the CommonsMultipartResolver, there could be differentiated between a general exception or a MaxUploadSizeExceededException.

Probably not an easy task as it depends on the container how it is handled and which exception is thrown.

For tomcat it is:

org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException.

Affects: 3.1.1

Issue Links:

Referenced from: commits 1922f03

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Aug 26, 2016

Juergen Hoeller commented

Tomcat may also throw a related exception in case of the total request size exceeded: org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (...) exceeds the configured maximum (...)

Jetty throws an IllegalStateException of the following kind: java.lang.IllegalStateException: Multipart Mime part file exceeds max filesize

So I guess we could at least do some educated guessing: If the exception class name or message contains the keywords "size" and "exceed", we throw the more specific MaxUploadSizeExceededException instead of our general MultipartException...

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Aug 29, 2016

Juergen Hoeller commented

The harder part is determining the actual size limits: They are available from the associated Servlet 3.0 MultipartConfig object, but unfortunately that's not accessible anywhere other than during a programmatic Servlet registration. We could nevertheless allow for passing it to the StandardServletMultipartResolver, e.g. in a web application initializer implementation or in a Spring Boot setup variant.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jan 16, 2017

Juergen Hoeller commented

I've rolled this in for 5.0 RC1 now, based on "size" and "exceed" keywords being detected, simply stubbing the maximum file size with -1 to indicate that it's not known. For richer exception reporting, we still recommend CommonsMultipartResolver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants