Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2016-02-03 05:59:31 -0500
committerJan Bartel2016-02-03 08:15:15 -0500
commitd151143556f941b7f8f7c02d41744ff3d34b9f4e (patch)
tree239799be0b6a58d3a399514ac4988a88fbd222b7
parent6c9a444b6c5b872f69bc452e84e76bce1426697a (diff)
downloadorg.eclipse.jetty.project-d151143556f941b7f8f7c02d41744ff3d34b9f4e.tar.gz
org.eclipse.jetty.project-d151143556f941b7f8f7c02d41744ff3d34b9f4e.tar.xz
org.eclipse.jetty.project-d151143556f941b7f8f7c02d41744ff3d34b9f4e.zip
Revert "486394 - MultipartConfig.fileSizeThreshold default of 0 should always create a file"
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartInputStreamParser.java30
1 files changed, 2 insertions, 28 deletions
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartInputStreamParser.java b/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartInputStreamParser.java
index 95fbcd635e..946d708c30 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartInputStreamParser.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartInputStreamParser.java
@@ -40,7 +40,6 @@ import java.util.List;
import java.util.Locale;
import javax.servlet.MultipartConfigElement;
-import javax.servlet.annotation.MultipartConfig;
import javax.servlet.http.Part;
import org.eclipse.jetty.util.log.Log;
@@ -113,7 +112,7 @@ public class MultiPartInputStreamParser
if (MultiPartInputStreamParser.this._config.getMaxFileSize() > 0 && _size + 1 > MultiPartInputStreamParser.this._config.getMaxFileSize())
throw new IllegalStateException ("Multipart Mime part "+_name+" exceeds max filesize");
- if (_file == null && MultiPartInputStreamParser.this.isFileNeeded(_size + 1))
+ if (MultiPartInputStreamParser.this._config.getFileSizeThreshold() > 0 && _size + 1 > MultiPartInputStreamParser.this._config.getFileSizeThreshold() && _file==null)
createFile();
_out.write(b);
@@ -126,7 +125,7 @@ public class MultiPartInputStreamParser
if (MultiPartInputStreamParser.this._config.getMaxFileSize() > 0 && _size + length > MultiPartInputStreamParser.this._config.getMaxFileSize())
throw new IllegalStateException ("Multipart Mime part "+_name+" exceeds max filesize");
- if (_file == null && MultiPartInputStreamParser.this.isFileNeeded(_size + length))
+ if (MultiPartInputStreamParser.this._config.getFileSizeThreshold() > 0 && _size + length > MultiPartInputStreamParser.this._config.getFileSizeThreshold() && _file==null)
createFile();
_out.write(bytes, offset, length);
@@ -431,31 +430,6 @@ public class MultiPartInputStreamParser
/**
- * Test to determine if the file content sizes exceeds the {@link MultipartConfig#fileSizeThreshold()}
- * necessary to produce a file on disk
- * <p>
- * Configured {@link MultipartConfig#fileSizeThreshold()} of <code>0</code> is always true, negative is always false,
- * all other configurations are tested against <code>size</code> parameter
- *
- * @param size the file size to test against.
- * @return true if file is needed, false otherwise
- */
- protected boolean isFileNeeded(long size)
- {
- if (_config.getFileSizeThreshold() < 0)
- {
- // Negative file size threshold means no file, ever
- return false;
- }
- if (_config.getFileSizeThreshold() == 0)
- {
- // 0 means always create a file
- return true;
- }
- return size > _config.getFileSizeThreshold();
- }
-
- /**
* Parse, if necessary, the multipart stream.
*
* @throws IOException if unable to parse

Back to the top