Repository: james-project
Updated Branches:
  refs/heads/master 90e28ece8 -> f0d88104c


JAMES-2252 Consume by copying to NULL_OUTPUT_STREAM

Consuming bytes individually can be inefficient if the input stream is
not buffered. IOUtils.copy() buffers the input internally, so there is
no need to use a BufferedInputStream.


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/6b464937
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/6b464937
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/6b464937

Branch: refs/heads/master
Commit: 6b46493717fc0e9d076471059e681ea0d78cfee3
Parents: 21188d0
Author: Daniel Trebbien <[email protected]>
Authored: Thu Oct 26 15:48:19 2017 -0400
Committer: benwa <[email protected]>
Committed: Fri Dec 8 14:16:02 2017 +0700

----------------------------------------------------------------------
 .../java/org/apache/james/imap/processor/AppendProcessor.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/6b464937/protocols/imap/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
----------------------------------------------------------------------
diff --git 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
index df3228f..1ec493d 100644
--- 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
+++ 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
@@ -26,6 +26,8 @@ import java.util.Date;
 
 import javax.mail.Flags;
 
+import org.apache.commons.io.IOUtils;
+import static org.apache.commons.io.output.NullOutputStream.NULL_OUTPUT_STREAM;
 import org.apache.james.imap.api.ImapCommand;
 import org.apache.james.imap.api.ImapSessionUtils;
 import org.apache.james.imap.api.display.HumanReadableText;
@@ -103,8 +105,9 @@ public class AppendProcessor extends 
AbstractMailboxProcessor<AppendRequest> {
 
     private void consume(InputStream in) {
         try {
-            while (in.read() != -1)
-                ; // NOPMD false positive
+            // IOUtils.copy() buffers the input internally, so there is no need
+            // to use a BufferedInputStream.
+            IOUtils.copy(in, NULL_OUTPUT_STREAM);
         } catch (IOException e1) { // NOPMD false positive
             // just consume
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to