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 2022/03/15 02:00:24 UTC

[james-project] 06/10: JAMES-3720 JMAP RFC-8621 Dispose EmailSubmission/set emails

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

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

commit cb6927104b4a69557ad09cfb088eeea262b686b2
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Mar 4 21:13:46 2022 +0700

    JAMES-3720 JMAP RFC-8621 Dispose EmailSubmission/set emails
    
    Previously not done, this sadly leads to temporary file leak for large mails...
    
    (cherry picked from commit 4d9be3f4346fe0ea50760c66671d43f7216e5256)
---
 .../apache/james/jmap/method/EmailSubmissionSetMethod.scala    | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala
index 6873e07..67786d3 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala
@@ -256,8 +256,8 @@ class EmailSubmissionSetMethod @Inject()(serializer: EmailSubmissionSetSerialize
       submissionId = EmailSubmissionId.generate
       message <- SMono.fromTry(toMimeMessage(submissionId.value, message))
       envelope <- SMono.fromTry(resolveEnvelope(message, request.envelope))
-      validation <- SMono.fromTry(validate(mailboxSession)(message, envelope))
-      mail <- SMono.fromCallable(() => {
+      _ <- SMono.fromTry(validate(mailboxSession)(message, envelope))
+      mail = {
         val mailImpl = MailImpl.builder()
           .name(submissionId.value)
           .addRecipients(envelope.rcptTo.map(_.email).asJava)
@@ -266,8 +266,10 @@ class EmailSubmissionSetMethod @Inject()(serializer: EmailSubmissionSetSerialize
           .build()
         mailImpl.setMessageNoCopy(message)
         mailImpl
-      })
-      enqueue <- SMono(queue.enqueueReactive(mail)).`then`(SMono.just(submissionId))
+      }
+      _ <- SMono(queue.enqueueReactive(mail))
+        .`then`(SMono.fromCallable(() => LifecycleUtil.dispose(mail)).subscribeOn(Schedulers.elastic()))
+        .`then`(SMono.just(submissionId))
     } yield {
       EmailSubmissionCreationResponse(submissionId) -> request.emailId
     }

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