james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [2/4] james-project git commit: JAMES-1945 Allow unboxing future stream for larger size
Date Tue, 21 Feb 2017 13:24:34 GMT
JAMES-1945 Allow unboxing future stream for larger size


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

Branch: refs/heads/master
Commit: 7d0fc2b4b6ef975e0a55562d488fb64c1b9e5882
Parents: 2b52e39
Author: Benoit Tellier <btellier@linagora.com>
Authored: Tue Feb 21 13:08:11 2017 +0700
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Tue Feb 21 14:23:08 2017 +0100

----------------------------------------------------------------------
 .../java/org/apache/james/util/CompletableFutureUtil.java |  1 +
 .../org/apache/james/util/CompletableFutureUtilTest.java  | 10 ++++++++++
 2 files changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/7d0fc2b4/server/container/util-java8/src/main/java/org/apache/james/util/CompletableFutureUtil.java
----------------------------------------------------------------------
diff --git a/server/container/util-java8/src/main/java/org/apache/james/util/CompletableFutureUtil.java
b/server/container/util-java8/src/main/java/org/apache/james/util/CompletableFutureUtil.java
index 651e1c6..b014592 100644
--- a/server/container/util-java8/src/main/java/org/apache/james/util/CompletableFutureUtil.java
+++ b/server/container/util-java8/src/main/java/org/apache/james/util/CompletableFutureUtil.java
@@ -27,6 +27,7 @@ public class CompletableFutureUtil {
     public static <T> CompletableFuture<Stream<T>> allOf(Stream<CompletableFuture<T>>
futureStream) {
         return futureStream
             .map((CompletableFuture<T> future) -> future.thenApply(Stream::of))
+            .parallel()
             .reduce((future1, future2) ->
             future1.thenCompose(
                 stream1 -> future2.thenCompose(

http://git-wip-us.apache.org/repos/asf/james-project/blob/7d0fc2b4/server/container/util-java8/src/test/java/org/apache/james/util/CompletableFutureUtilTest.java
----------------------------------------------------------------------
diff --git a/server/container/util-java8/src/test/java/org/apache/james/util/CompletableFutureUtilTest.java
b/server/container/util-java8/src/test/java/org/apache/james/util/CompletableFutureUtilTest.java
index fa12233..144cf42 100644
--- a/server/container/util-java8/src/test/java/org/apache/james/util/CompletableFutureUtilTest.java
+++ b/server/container/util-java8/src/test/java/org/apache/james/util/CompletableFutureUtilTest.java
@@ -22,6 +22,7 @@ package org.apache.james.util;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.concurrent.CompletableFuture;
+import java.util.stream.IntStream;
 import java.util.stream.Stream;
 
 import org.junit.Test;
@@ -54,4 +55,13 @@ public class CompletableFutureUtilTest {
                 .collect(Guavate.toImmutableList()))
             .containsOnly(value1, value2, value3);
     }
+
+    @Test
+    public void allOfShouldWorkOnVeryLargeStream() {
+        CompletableFutureUtil.allOf(
+            IntStream.range(0, 100000)
+                .boxed()
+                .map(CompletableFuture::completedFuture))
+            .join();
+    }
 }


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


Mime
View raw message