You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by jo...@apache.org on 2019/03/25 14:04:59 UTC
[commons-fileupload] branch master updated: Reuse Buffer: Using the
same buffer speeds up the parsing process by about 10% (Part-Revert
4ed6e923cb2033272fcb993978d69e325990a5aa)
This is an automated email from the ASF dual-hosted git repository.
jochen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-fileupload.git
The following commit(s) were added to refs/heads/master by this push:
new 10d22ac Reuse Buffer: Using the same buffer speeds up the parsing process by about 10% (Part-Revert 4ed6e923cb2033272fcb993978d69e325990a5aa)
new 4938b9c This closes 18
10d22ac is described below
commit 10d22ac91834cc61a7de41451be1d1f15e881733
Author: David Georg Reichelt <da...@dagere.de>
AuthorDate: Mon Mar 18 10:44:53 2019 +0100
Reuse Buffer: Using the same buffer speeds up the parsing process by about 10% (Part-Revert 4ed6e923cb2033272fcb993978d69e325990a5aa)
---
src/main/java/org/apache/commons/fileupload2/FileUploadBase.java | 3 ++-
src/main/java/org/apache/commons/fileupload2/util/Streams.java | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/commons/fileupload2/FileUploadBase.java b/src/main/java/org/apache/commons/fileupload2/FileUploadBase.java
index 6341bbd..777f34d 100644
--- a/src/main/java/org/apache/commons/fileupload2/FileUploadBase.java
+++ b/src/main/java/org/apache/commons/fileupload2/FileUploadBase.java
@@ -332,6 +332,7 @@ public abstract class FileUploadBase {
try {
FileItemIterator iter = getItemIterator(ctx);
FileItemFactory fac = getFileItemFactory();
+ final byte[] buffer = new byte[Streams.DEFAULT_BUFFER_SIZE];
if (fac == null) {
throw new NullPointerException("No FileItemFactory has been set.");
}
@@ -343,7 +344,7 @@ public abstract class FileUploadBase {
item.isFormField(), fileName);
items.add(fileItem);
try {
- Streams.copy(item.openStream(), fileItem.getOutputStream(), true);
+ Streams.copy(item.openStream(), fileItem.getOutputStream(), true, buffer);
} catch (FileUploadIOException e) {
throw (FileUploadException) e.getCause();
} catch (IOException e) {
diff --git a/src/main/java/org/apache/commons/fileupload2/util/Streams.java b/src/main/java/org/apache/commons/fileupload2/util/Streams.java
index 8f82a44..b2ff7ce 100644
--- a/src/main/java/org/apache/commons/fileupload2/util/Streams.java
+++ b/src/main/java/org/apache/commons/fileupload2/util/Streams.java
@@ -41,7 +41,7 @@ public final class Streams {
* Default buffer size for use in
* {@link #copy(InputStream, OutputStream, boolean)}.
*/
- private static final int DEFAULT_BUFFER_SIZE = 8192;
+ public static final int DEFAULT_BUFFER_SIZE = 8192;
/**
* Copies the contents of the given {@link InputStream}