This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch feature/WW-5401-logging in repository https://gitbox.apache.org/repos/asf/struts.git
commit f459981022677b58e65191c5256a16a1cd1114d3 Author: Lukasz Lenart <lukaszlen...@apache.org> AuthorDate: Wed Mar 6 08:09:09 2024 +0100 WW-5401 Improves logging around wrapping request and detecting multipart request --- .../main/java/org/apache/struts2/dispatcher/Dispatcher.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java index 70b85e1b7..fadbc1bd9 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java @@ -986,10 +986,12 @@ public class Dispatcher { public HttpServletRequest wrapRequest(HttpServletRequest request) throws IOException { // don't wrap more than once if (request instanceof StrutsRequestWrapper) { + LOG.debug("Request already wrapped with {}", StrutsRequestWrapper.class.getSimpleName()); return request; } if (isMultipartSupportEnabled(request) && isMultipartRequest(request)) { + LOG.debug("Wrapping multipart request with: {}", MultiPartRequestWrapper.class.getSimpleName()); request = new MultiPartRequestWrapper( getMultiPartRequest(), request, @@ -998,6 +1000,7 @@ public class Dispatcher { disableRequestAttributeValueStackLookup ); } else { + LOG.debug("Wrapping request using: {}", StrutsRequestWrapper.class.getSimpleName()); request = new StrutsRequestWrapper(request, disableRequestAttributeValueStackLookup); } @@ -1012,6 +1015,7 @@ public class Dispatcher { * @since 2.5.11 */ protected boolean isMultipartSupportEnabled(HttpServletRequest request) { + LOG.debug("Support for multipart request is enabled: {}", multipartSupportEnabled); return multipartSupportEnabled; } @@ -1026,9 +1030,12 @@ public class Dispatcher { String httpMethod = request.getMethod(); String contentType = request.getContentType(); - return REQUEST_POST_METHOD.equalsIgnoreCase(httpMethod) && - contentType != null && - multipartValidationPattern.matcher(contentType.toLowerCase(Locale.ENGLISH)).matches(); + boolean isPostRequest = REQUEST_POST_METHOD.equalsIgnoreCase(httpMethod); + boolean isProperContentType = contentType != null && multipartValidationPattern.matcher(contentType.toLowerCase(Locale.ENGLISH)).matches(); + + LOG.debug("Validating if this is proper Multipart request. Request is POST: {} and ContentType matches pattern ({}): {}", + isPostRequest, multipartValidationPattern, isProperContentType); + return isPostRequest && isProperContentType; } /**