james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [1/4] james-project git commit: JAMES-1945 Allow unboxing future stream for larger size
Date Tue, 21 Feb 2017 13:21:21 GMT
Repository: james-project
Updated Branches:
  refs/heads/JAMES-1945 [created] 83da2e2f2


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/3e60185f
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/3e60185f
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/3e60185f

Branch: refs/heads/JAMES-1945
Commit: 3e60185f1b115ac9283e20c164c7b45012072987
Parents: 4c51eae
Author: Benoit Tellier <btellier@linagora.com>
Authored: Tue Feb 21 13:08:11 2017 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Tue Feb 21 13:10:15 2017 +0700

----------------------------------------------------------------------
 .../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/3e60185f/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/3e60185f/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