DispatcherServet.checkMultipart considers MultipartException cause as well

Issue: SPR-15178
This commit is contained in:
Juergen Hoeller
2017-01-23 21:22:38 +01:00
parent 7d3fcaa934
commit ecc22f7179

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1091,7 +1091,7 @@ public class DispatcherServlet extends FrameworkServlet {
logger.debug("Request is already a MultipartHttpServletRequest - if not in a forward, " +
"this typically results from an additional MultipartFilter in web.xml");
}
else if (request.getAttribute(WebUtils.ERROR_EXCEPTION_ATTRIBUTE) instanceof MultipartException) {
else if (hasMultipartException(request) ) {
logger.debug("Multipart resolution failed for current request before - " +
"skipping re-resolution for undisturbed error rendering");
}
@@ -1103,6 +1103,20 @@ public class DispatcherServlet extends FrameworkServlet {
return request;
}
/**
* Check "javax.servlet.error.exception" attribute for a multipart exception.
*/
private boolean hasMultipartException(HttpServletRequest request) {
Throwable error = (Throwable) request.getAttribute(WebUtils.ERROR_EXCEPTION_ATTRIBUTE);
while (error != null) {
if (error instanceof MultipartException) {
return true;
}
error = error.getCause();
}
return false;
}
/**
* Clean up any resources used by the given multipart request (if any).
* @param request current HTTP request