Repository: james-project
Updated Branches:
  refs/heads/master ce8cf479a -> 0e3ffde31


JAMES-2612 Refactor MessageBatcher


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

Branch: refs/heads/master
Commit: 0e3ffde315a977a4769d0c69a76743918da502f1
Parents: 48ef09c
Author: Antoine Duprat <adup...@linagora.com>
Authored: Thu Nov 29 09:58:15 2018 +0100
Committer: Raphael Ouazana <raphael.ouaz...@linagora.com>
Committed: Mon Dec 3 11:16:29 2018 +0100

----------------------------------------------------------------------
 .../org/apache/james/mailbox/store/MessageBatcher.java | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0e3ffde3/mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageBatcher.java
----------------------------------------------------------------------
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageBatcher.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageBatcher.java
index 9f1fdc8..6c6509c 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageBatcher.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageBatcher.java
@@ -19,12 +19,13 @@
 
 package org.apache.james.mailbox.store;
 
-import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MessageRange;
 
+import com.github.fge.lambdas.Throwing;
+import com.github.steveash.guavate.Guavate;
 import com.google.common.base.Preconditions;
 
 public class MessageBatcher {
@@ -48,11 +49,11 @@ public class MessageBatcher {
 
     public List<MessageRange> batchMessages(MessageRange set, BatchedOperation 
batchedOperation) throws MailboxException {
         if (batchSize > 0) {
-            List<MessageRange> movedRanges = new ArrayList<>();
-            for (MessageRange messageRange : set.split(batchSize)) {
-                movedRanges.addAll(batchedOperation.execute(messageRange));
-            }
-            return movedRanges;
+            return set.split(batchSize)
+                .stream()
+                .flatMap(Throwing.function(range -> 
batchedOperation.execute(range)
+                                                                    .stream()))
+                .collect(Guavate.toImmutableList());
         } else {
             return batchedOperation.execute(set);
         }


---------------------------------------------------------------------
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