This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-mime4j.git

commit 215f8ed3107909a1b8671b8e0f2c5063d2f626fe
Author: Benoit Tellier <btell...@linagora.com>
AuthorDate: Mon Jun 20 11:06:02 2022 +0700

    MIME4J-318 Adopt commons-io ByteArrayOutputStream
    
    Parsing 100K messages locally drops from 5.6s to 4.9s...
---
 core/pom.xml                                         |  1 -
 .../org/apache/james/mime4j/util/ContentUtil.java    |  2 +-
 .../java/org/apache/james/mime4j/dom/SingleBody.java | 20 +++-----------------
 3 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/core/pom.xml b/core/pom.xml
index 216e1eb5..0123a688 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -41,7 +41,6 @@
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
-            <scope>test</scope>
         </dependency>
     </dependencies>
 
diff --git a/core/src/main/java/org/apache/james/mime4j/util/ContentUtil.java 
b/core/src/main/java/org/apache/james/mime4j/util/ContentUtil.java
index 14a636b6..b519f4dd 100644
--- a/core/src/main/java/org/apache/james/mime4j/util/ContentUtil.java
+++ b/core/src/main/java/org/apache/james/mime4j/util/ContentUtil.java
@@ -19,7 +19,6 @@
 
 package org.apache.james.mime4j.util;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -31,6 +30,7 @@ import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
 import java.nio.charset.Charset;
 
+import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.james.mime4j.Charsets;
 
 /**
diff --git a/dom/src/main/java/org/apache/james/mime4j/dom/SingleBody.java 
b/dom/src/main/java/org/apache/james/mime4j/dom/SingleBody.java
index c75cad0d..ea421114 100644
--- a/dom/src/main/java/org/apache/james/mime4j/dom/SingleBody.java
+++ b/dom/src/main/java/org/apache/james/mime4j/dom/SingleBody.java
@@ -23,6 +23,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import org.apache.james.mime4j.util.ContentUtil;
+
 /**
  * Abstract implementation of a single message body; that is, a body that does
  * not contain (directly or indirectly) any other child bodies. It also 
provides
@@ -76,7 +78,7 @@ public abstract class SingleBody implements Body {
             throw new IllegalArgumentException();
 
         InputStream in = getInputStream();
-        SingleBody.copy(in, out);
+        ContentUtil.copy(in, out);
         in.close();
     }
 
@@ -120,20 +122,4 @@ public abstract class SingleBody implements Body {
     public void dispose() {
     }
 
-    static final int DEFAULT_ENCODING_BUFFER_SIZE = 1024;
-
-    /**
-     * Copies the contents of one stream to the other.
-     * @param in not null
-     * @param out not null
-     * @throws IOException
-     */
-    private static void copy(final InputStream in, final OutputStream out) 
throws IOException {
-        final byte[] buffer = new byte[DEFAULT_ENCODING_BUFFER_SIZE];
-        int inputLength;
-        while (-1 != (inputLength = in.read(buffer))) {
-            out.write(buffer, 0, inputLength);
-        }
-    }
-
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to