From 10838a636fbbd4a95ac3652bc7209e98c6a11f6c Mon Sep 17 00:00:00 2001 From: kacperkrzyzak Date: Tue, 5 Jul 2022 14:55:42 +0200 Subject: [PATCH] Correctly identify MaxUploadSizeExceededException in StandardMultipartHttpServletRequest This commit correctly identifies MaxUploadSizeExceededException in StandardMultipartHttpServletRequest by converting keywords in the exception message to lowercase before checking for their presence, for compatibility with Jetty 9.4.x. Closes gh-28759 --- .../support/StandardMultipartHttpServletRequest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java b/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java index 6970c8e12e..ac367a2a5e 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java @@ -118,8 +118,11 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe protected void handleParseFailure(Throwable ex) { String msg = ex.getMessage(); - if (msg != null && msg.contains("size") && msg.contains("exceed")) { - throw new MaxUploadSizeExceededException(-1, ex); + if (msg != null) { + msg = msg.toLowerCase(); + if (msg.contains("size") && msg.contains("exceed")) { + throw new MaxUploadSizeExceededException(-1, ex); + } } throw new MultipartException("Failed to parse multipart servlet request", ex); }