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

Fixes #4470 - Add logging to FileUploadManager for debugging purposes #4485

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
* The ApacheMultiPartManager.
*
* <p>
The FileUploadMultiPartManager implements the MultiPartManager API that delivers
file upload functionality to a web application by delegating to Apache
Commons File Upload.
</p>
* The FileUploadMultiPartManager implements the MultiPartManager API that
* delivers file upload functionality to a web application by delegating to
* Apache Commons File Upload.
* </p>
*
* @author Manfred Riem (mriem@manorrock.com)
*/
Expand All @@ -73,9 +73,14 @@ public FileUploadMultiPartManager() {
@SuppressWarnings("unchecked")
@Override
public Collection<Part> getParts(WebApplication webApplication, WebApplicationRequest request) throws ServletException {
LOGGER.log(TRACE, "Getting parts for request: {0}", request);

if (LOGGER.isLoggable(TRACE)) {
LOGGER.log(TRACE, "Getting parts for request: {0}", request);
}

if (!JakartaServletFileUpload.isMultipartContent(request)) {
if (LOGGER.isLoggable(TRACE)) {
LOGGER.log(TRACE, "Request: {0} is not a multipart/form-date request");
}
throw new ServletException("Not a multipart/form-data request");
}

Expand All @@ -98,15 +103,26 @@ public Collection<Part> getParts(WebApplication webApplication, WebApplicationRe

@Override
public Part getPart(WebApplication webApplication, WebApplicationRequest request, String name) throws ServletException {
LOGGER.log(TRACE, "Getting part: {0} for request: {1}", name, request);
if (LOGGER.isLoggable(TRACE)) {
LOGGER.log(TRACE, "Getting part: {0} for request: {1}", name, request);
}
if (!JakartaServletFileUpload.isMultipartContent(request)) {
if (LOGGER.isLoggable(TRACE)) {
LOGGER.log(TRACE, "Request: {0} is not a multipart/form-date request");
}
throw new ServletException("Not a multipart/form-data request");
}
for (Part part : getParts(webApplication, request)) {
if (part.getName().equals(name)) {
if (LOGGER.isLoggable(TRACE)) {
LOGGER.log(TRACE, "Found part: {0}", part.getName());
}
return part;
}
}
if (LOGGER.isLoggable(TRACE)) {
LOGGER.log(TRACE, "Unable to find part: {0}", name);
}
return null;
}

Expand Down
Loading