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

MultiPart files should be written to disk by default #10936

Closed
essobedo opened this issue Nov 28, 2023 · 4 comments
Closed

MultiPart files should be written to disk by default #10936

essobedo opened this issue Nov 28, 2023 · 4 comments
Labels
Bug For general bugs on Jetty side

Comments

@essobedo
Copy link

Description

In Jakarta EE 10, the expected behavior when fileSizeThreshold is set to 0 aka the default value has been clearly specified as you can see in the Javadoc.

I quote:

A value of zero means files must always be written to disk.

The current behavior of Jetty is not compliant since only strictly positive values are taken into account.

@essobedo essobedo added the Bug For general bugs on Jetty side label Nov 28, 2023
essobedo added a commit to essobedo/jetty.project that referenced this issue Nov 28, 2023
@essobedo
Copy link
Author

A potential fix for it #10937

@joakime
Copy link
Contributor

joakime commented Nov 28, 2023

The first version of Jetty that supports EE10 / Servlet 6.0 specs (where this language about fileSizeThreshold value of 0) is Jetty 12 on the ee10 environment.

@joakime
Copy link
Contributor

joakime commented Nov 28, 2023

Jetty 12 has support for fileSizeThreshold value of 0 in the EE10 environment already.

See EE10 handling ...

Which uses jetty-core handling ...

/**
* <p>Sets the maximum memory file size in bytes, after which files will be saved
* in the directory specified by {@link #setFilesDirectory(Path)}.</p>
* <p>Use value {@code 0} to always save the files in the directory.</p>
* <p>Use value {@code -1} to never save the files in the directory.</p>
*
* @param maxMemoryFileSize the maximum memory file size in bytes, or -1 for unlimited memory file size
*/
public void setMaxMemoryFileSize(long maxMemoryFileSize)
{
this.maxMemoryFileSize = maxMemoryFileSize;
}

Which is implemented here ...

long maxMemoryFileSize = getMaxMemoryFileSize();
if (maxMemoryFileSize >= 0)
{
memoryFileSize += buffer.remaining();
if (memoryFileSize > maxMemoryFileSize)
{
try
{
// Must save to disk.
if (ensureFileChannel())
{
// Write existing memory chunks.

@essobedo
Copy link
Author

Yeah I've just realized that, thx for the quick feedback

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
None yet
Development

No branches or pull requests

2 participants