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 54750a407ffff1695a9c0e79b1412a845e99db46 Author: Benoit Tellier <[email protected]> AuthorDate: Fri Mar 4 21:14:52 2022 +0700 JAMES-3720 JMAP RFC-8621 Dispose MDN/send emails Previously not done, this sadly leads to temporary file leak for large mails... Though for MDNs we are unlikely to go over 100KB (from where temp file start being used)... (cherry picked from commit 024378027ed7bb3b1a9f1094517b8db260bba135) --- .../scala/org/apache/james/jmap/method/MDNSendMethod.scala | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MDNSendMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MDNSendMethod.scala index 6ce362d..474e4aa 100644 --- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MDNSendMethod.scala +++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MDNSendMethod.scala @@ -33,7 +33,7 @@ import org.apache.james.jmap.mail.MDNSend.MDN_ALREADY_SENT_FLAG import org.apache.james.jmap.mail._ import org.apache.james.jmap.method.EmailSubmissionSetMethod.LOGGER import org.apache.james.jmap.routes.{ProcessingContext, SessionSupplier} -import org.apache.james.lifecycle.api.Startable +import org.apache.james.lifecycle.api.{LifecycleUtil, Startable} import org.apache.james.mailbox.model.{FetchGroup, MessageResult} import org.apache.james.mailbox.{MailboxSession, MessageIdManager} import org.apache.james.mdn.fields.{ExtensionField, FinalRecipient, OriginalRecipient, Text} @@ -149,7 +149,7 @@ class MDNSendMethod @Inject()(serializer: MDNSerializer, mdnRelatedMessageResultAlready <- validateMDNNotAlreadySent(mdnRelatedMessageResult) messageRelated = parseAsMessage(mdnRelatedMessageResultAlready) mailAndResponseAndId <- buildMailAndResponse(identity, session.getUser.asString(), requestEntry, messageRelated) - _ <- Try(queue.enQueue(mailAndResponseAndId._1)).toEither + _ <- Try(enqueue(mailAndResponseAndId._1)).toEither } yield { MDNSendCreateSuccess( mdnCreationId = mdnSendCreationId, @@ -157,6 +157,12 @@ class MDNSendMethod @Inject()(serializer: MDNSerializer, forEmailId = mdnRelatedMessageResultAlready.getMessageId) } + private def enqueue(mail: MailImpl): Unit = try { + queue.enQueue(mail) + } finally { + LifecycleUtil.dispose(mail) + } + private def retrieveRelatedMessageResult(session: MailboxSession, requestEntry: MDNSendCreateRequest): Either[MDNSendNotFoundException, MessageResult] = messageIdManager.getMessage(requestEntry.forEmailId.originalMessageId, FetchGroup.FULL_CONTENT, session) .asScala --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
