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

Jetty Part#delete() implementation throws IOException #11944

Closed
maartenc opened this issue Jun 21, 2024 · 2 comments · Fixed by #11945
Closed

Jetty Part#delete() implementation throws IOException #11944

maartenc opened this issue Jun 21, 2024 · 2 comments · Fixed by #11945
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@maartenc
Copy link

Jetty version(s)
Jetty 12.0.7

Jetty Environment
ee10

Java version/vendor (use: java -version)
java version "21.0.1" 2023-10-17 LTS
Java(TM) SE Runtime Environment (build 21.0.1+12-LTS-29)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.1+12-LTS-29, mixed mode, sharing)

OS type/version
Microsoft Windows [Version 10.0.19045.4412]

Description
Recently, we upgraded from Jetty 9.4.x to 12.0.7. We are using Spring Boot 3.2.1. After the upgrade, we noticed warnings being logged when uploading files through Jetty. The warnings are logged by the StandardServletMultipartResolver of Spring which tries to delete all the Parts of the multipart/form-data request after it has been handled by the application.

After doing some investigation, it turns out the implementation of jakarta.servlet.http.Part#delete() in Jetty 12 throws an IOException if the file doesn't exist (see org.eclipse.jetty.http.MultiPart$Part#delete()). In Jetty 9, this wasn't the case. In that version, a File#exists() check is done before the file get deleted (see org.eclipse.jetty.util.MultiPartInputStreamParser$MultiPart#delete()).

In our situation, we already delete these files in our application code. So it's normal that the files doesn't exist any more when the StandardServletMultipartResolver of Spring tries to cleanup the uploaded files. Would it be possible to add a similar file-exist check to Jetty 12 in the org.eclipse.jetty.http.MultiPart$Part#delete() method to avoid throwing IOExceptions for files that don't exist (any more)?

@joakime
Copy link
Contributor

joakime commented Jun 21, 2024

Opened PR #11945

joakime added a commit that referenced this issue Jun 24, 2024
…-existence-check

Issue #11944 - Part.delete() should only attempt to delete if the file exists
@joakime
Copy link
Contributor

joakime commented Jun 24, 2024

PR #11945 merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
No open projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants