You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2024/06/24 08:08:29 UTC

(james-project) 20/34: [UPGRADE] MAVEN - reactor & netty

This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit bfdc806a15723462c8dbbd3572c45cff7e4d9f4a
Author: vttran <vt...@linagora.com>
AuthorDate: Mon Jun 17 15:11:02 2024 +0700

    [UPGRADE] MAVEN - reactor & netty
    
    - reactor-bom: 2023.0.0 -> 2023.0.7
    - netty.version: 4.1.101.Final -> 4.1.110.Final
---
 examples/custom-healthcheck/pom.xml                |  2 +-
 pom.xml                                            |  4 +--
 .../apache/james/jmap/routes/DownloadRoutes.scala  | 33 +++++++++++++---------
 server/queue/queue-activemq/pom.xml                |  2 --
 4 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/examples/custom-healthcheck/pom.xml b/examples/custom-healthcheck/pom.xml
index 49ff11cf30..f699edf475 100644
--- a/examples/custom-healthcheck/pom.xml
+++ b/examples/custom-healthcheck/pom.xml
@@ -39,7 +39,7 @@
         <dependency>
             <groupId>io.projectreactor</groupId>
             <artifactId>reactor-core</artifactId>
-            <version>3.5.8</version>
+            <version>3.6.7</version>
             <scope>provided</scope>
         </dependency>
     </dependencies>
diff --git a/pom.xml b/pom.xml
index 7e5d2e824a..5be4879bda 100644
--- a/pom.xml
+++ b/pom.xml
@@ -620,7 +620,7 @@
         <junit.platform.version>1.9.3</junit.platform.version>
         <junit.vintage.version>5.9.3</junit.vintage.version>
         <concurrent.version>1.3.4</concurrent.version>
-        <netty.version>4.1.101.Final</netty.version>
+        <netty.version>4.1.110.Final</netty.version>
         <cucumber.version>7.15.0</cucumber.version>
 
         <jackson.version>2.17.1</jackson.version>
@@ -2455,7 +2455,7 @@
             <dependency>
                 <groupId>io.projectreactor</groupId>
                 <artifactId>reactor-bom</artifactId>
-                <version>2023.0.0</version>
+                <version>2023.0.7</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/DownloadRoutes.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/DownloadRoutes.scala
index 40e1119709..ea4aba7f8b 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/DownloadRoutes.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/DownloadRoutes.scala
@@ -20,6 +20,8 @@ package org.apache.james.jmap.routes
 
 import java.io.InputStream
 import java.nio.charset.StandardCharsets
+import java.util.concurrent.Callable
+import java.util.function.Consumer
 import java.util.stream
 import java.util.stream.Stream
 
@@ -29,7 +31,7 @@ import eu.timepit.refined.refineV
 import io.netty.buffer.Unpooled
 import io.netty.handler.codec.http.HttpHeaderNames.{CONTENT_LENGTH, CONTENT_TYPE}
 import io.netty.handler.codec.http.HttpResponseStatus._
-import io.netty.handler.codec.http.{HttpHeaderValidationUtil, HttpMethod, HttpResponseStatus, QueryStringDecoder}
+import io.netty.handler.codec.http.{HttpHeaderValidationUtil, HttpMethod, QueryStringDecoder}
 import jakarta.inject.{Inject, Named}
 import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream
 import org.apache.james.jmap.HttpConstants.JSON_CONTENT_TYPE
@@ -62,7 +64,6 @@ import reactor.core.scala.publisher.SMono
 import reactor.core.scheduler.Schedulers
 import reactor.netty.http.server.{HttpServerRequest, HttpServerResponse}
 
-import scala.compat.java8.FunctionConverters._
 import scala.jdk.CollectionConverters._
 import scala.util.{Failure, Success, Try}
 
@@ -310,20 +311,24 @@ class DownloadRoutes @Inject()(@Named(InjectionKeys.RFC_8621) val authenticator:
   private def downloadBlob(optionalName: Option[String],
                            response: HttpServerResponse,
                            blobContentType: ContentType,
-                           blob: Blob): SMono[Unit] =
+                           blob: Blob): SMono[Unit] = {
+    val resourceSupplier: Callable[InputStream] = () => blob.content
+    val sourceSupplier: java.util.function.Function[InputStream, Mono[Void]] = stream => SMono(addContentDispositionHeader(optionalName)
+      .compose(addContentLengthHeader(blob.size))
+      .apply(response)
+      .header(CONTENT_TYPE, sanitizeHeaderValue(blobContentType.asString))
+      .status(OK)
+      .send(ReactorUtils.toChunks(stream, BUFFER_SIZE)
+        .map(Unpooled.wrappedBuffer(_))
+        .subscribeOn(Schedulers.boundedElastic()))).asJava()
+    val resourceRelease: Consumer[InputStream] = (stream: InputStream) => stream.close()
+
     SMono.fromPublisher(Mono.using(
-      () => blob.content,
-      (stream: InputStream) => addContentDispositionHeader(optionalName)
-        .compose(addContentLengthHeader(blob.size))
-        .apply(response)
-        .header(CONTENT_TYPE, sanitizeHeaderValue(blobContentType.asString))
-        .status(OK)
-        .send(ReactorUtils.toChunks(stream, BUFFER_SIZE)
-          .map(Unpooled.wrappedBuffer(_))
-          .subscribeOn(Schedulers.boundedElastic()))
-        .`then`,
-      asJavaConsumer[InputStream]((stream: InputStream) => stream.close())))
+        resourceSupplier,
+        sourceSupplier,
+        resourceRelease))
       .`then`
+  }
 
   private def addContentDispositionHeader(optionalName: Option[String]): HttpServerResponse => HttpServerResponse =
     resp => optionalName.map(addContentDispositionHeaderRegardingEncoding(_, resp))
diff --git a/server/queue/queue-activemq/pom.xml b/server/queue/queue-activemq/pom.xml
index c39810a8ed..aa95483776 100644
--- a/server/queue/queue-activemq/pom.xml
+++ b/server/queue/queue-activemq/pom.xml
@@ -33,12 +33,10 @@
     <name>Apache James :: Server :: Mail Queue :: ActiveMQ</name>
 
     <dependencies>
-        <!-- Forcing netty-transport version -->
         <dependency>
             <?SORTPOM IGNORE?>
             <groupId>io.netty</groupId>
             <artifactId>netty-transport</artifactId>
-            <version>4.1.77.Final</version>
             <?SORTPOM RESUME?>
         </dependency>
         <dependency>


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