You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2023/04/13 07:23:08 UTC

[james-project] 04/07: [PERF] Schedule Data chunker on boundedElastic

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-project.git

commit a453247026d18390e518f33f2d9bc62f2feced73
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed Apr 12 13:44:09 2023 +0700

    [PERF] Schedule Data chunker on boundedElastic
    
    Reading an inputstream is blocking.
---
 .../util/src/main/java/org/apache/james/util/DataChunker.java        | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/server/container/util/src/main/java/org/apache/james/util/DataChunker.java b/server/container/util/src/main/java/org/apache/james/util/DataChunker.java
index 9dea8e9050..0db274d32f 100644
--- a/server/container/util/src/main/java/org/apache/james/util/DataChunker.java
+++ b/server/container/util/src/main/java/org/apache/james/util/DataChunker.java
@@ -29,6 +29,7 @@ import com.google.common.base.Preconditions;
 
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
+import reactor.core.scheduler.Schedulers;
 
 public class DataChunker {
 
@@ -58,8 +59,7 @@ public class DataChunker {
         Preconditions.checkNotNull(data);
         Preconditions.checkArgument(chunkSize > 0, CHUNK_SIZE_MUST_BE_STRICTLY_POSITIVE);
         UnsynchronizedBufferedInputStream bufferedInputStream = new UnsynchronizedBufferedInputStream(data);
-        return Flux
-            .<ByteBuffer>generate(sink -> {
+        return Flux.<ByteBuffer>generate(sink -> {
                 try {
                     byte[] buffer = new byte[chunkSize];
 
@@ -73,6 +73,7 @@ public class DataChunker {
                     sink.error(e);
                 }
             })
+            .subscribeOn(Schedulers.boundedElastic())
             .defaultIfEmpty(ByteBuffer.wrap(new byte[0]));
     }
 }


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