Skip to content

WW-5573 Multipart stream file cleanup#1445

Merged
lukaszlenart merged 1 commit into
apache:release/struts-6-8-xfrom
ryanmurf:multipartCleanup
Dec 11, 2025
Merged

WW-5573 Multipart stream file cleanup#1445
lukaszlenart merged 1 commit into
apache:release/struts-6-8-xfrom
ryanmurf:multipartCleanup

Conversation

@ryanmurf
Copy link
Copy Markdown

@ryanmurf ryanmurf commented Dec 3, 2025

Refs WW-5573

Copilot AI review requested due to automatic review settings December 3, 2025 18:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the robustness of multipart file upload cleanup in Apache Struts by adding exception handling to ensure cleanup operations continue even when individual file deletions fail.

Key changes:

  • Added try-catch blocks around file cleanup operations to prevent individual failures from stopping the cleanup of other files
  • Refactored file item tracking in JakartaMultiPartRequest to add all items upfront, ensuring cleanup even if processing throws an exception

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
JakartaStreamMultiPartRequest.java Added try-catch exception handling in cleanUp() method to ensure all files are attempted for deletion even if individual deletions fail
JakartaMultiPartRequest.java Changed file item tracking to use addAll() before the processing loop, ensuring all parsed items are tracked for cleanup even if processing throws an exception mid-loop

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lukaszlenart
Copy link
Copy Markdown
Member

Is this PR related to the latest CVE?

@ryanmurf
Copy link
Copy Markdown
Author

ryanmurf commented Dec 6, 2025

Is this PR related to the latest CVE?

I noticed that the cleanup commit for WW-5573 handled exceptions in both the stream and non-stream multipart upload cleanup methods. The later commit added a try/catch block, but only for the non-stream path, so I updated the code to make the behavior consistent.

For the other change, I noticed when running tests on older branches that a NullPointerException in processNormalFormField (fixed here) could prevent files from being added to allFileItems, resulting in them not being cleaned up. This change should also help ensure proper cleanup if a similar issue occurs while processing FileItems.

@lukaszlenart lukaszlenart changed the title multipart stream file cleanup WW-5573 Multipart stream file cleanup Dec 7, 2025
@lukaszlenart lukaszlenart changed the base branch from release/struts-6-7-x to release/struts-6-8-x December 7, 2025 07:50
@lukaszlenart
Copy link
Copy Markdown
Member

Thanks @ryanmurf, I created a new branch and rebased your PR

@lukaszlenart lukaszlenart merged commit b490e2c into apache:release/struts-6-8-x Dec 11, 2025
7 checks passed
@lukaszlenart lukaszlenart added this to the 6.9.0 milestone Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants