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 95288d0d0a4cb5708dd84695648a9c8978f227a2
Author: Benoit TELLIER <btell...@linagora.com>
AuthorDate: Thu Oct 10 09:52:48 2024 +0200

    [REFACTORING] CreateProcessor: inline unneeded flatMap
---
 .../james/imap/processor/CreateProcessor.java      | 35 +++++++++++-----------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/CreateProcessor.java
 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/CreateProcessor.java
index 99fc531c35..377f5726f0 100644
--- 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/CreateProcessor.java
+++ 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/CreateProcessor.java
@@ -30,6 +30,7 @@ import org.apache.james.imap.message.request.CreateRequest;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.exception.MailboxExistsException;
 import org.apache.james.mailbox.exception.TooLongMailboxNameException;
+import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.util.MDCBuilder;
 import org.apache.james.util.ReactorUtils;
@@ -54,23 +55,23 @@ public class CreateProcessor extends 
AbstractMailboxProcessor<CreateRequest> {
     protected Mono<Void> processRequestReactive(CreateRequest request, 
ImapSession session, Responder responder) {
         MailboxManager mailboxManager = getMailboxManager();
 
-        return Mono.fromCallable(() -> 
pathConverterFactory.forSession(session).buildFullPath(request.getMailboxName()))
-            .flatMap(mailboxPath -> 
Mono.from(mailboxManager.createMailboxReactive(mailboxPath, 
session.getMailboxSession()))
-                .flatMap(mailboxId -> unsolicitedResponses(session, responder, 
false)
-                    .then(Mono.fromRunnable(() -> okComplete(request, 
StatusResponse.ResponseCode.mailboxId(mailboxId), responder))))
-                .onErrorResume(MailboxExistsException.class, e -> {
-                    no(request, responder, HumanReadableText.MAILBOX_EXISTS);
-                    return ReactorUtils.logAsMono(() -> LOGGER.debug("Create 
failed for mailbox {} as it already exists", mailboxPath, e));
-                })
-                .onErrorResume(TooLongMailboxNameException.class, e -> {
-                    taggedBad(request, responder, 
HumanReadableText.FAILURE_MAILBOX_NAME);
-                    return ReactorUtils.logAsMono(() -> LOGGER.debug("The 
mailbox name length is over limit: {}", mailboxPath.getName(), e));
-                })
-                .onErrorResume(TooLongMailboxNameException.class, e -> {
-                    no(request, responder, 
HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING);
-                    return ReactorUtils.logAsMono(() -> LOGGER.error("Create 
failed for mailbox {}", mailboxPath, e));
-                })
-                .then());
+        MailboxPath mailboxPath = 
pathConverterFactory.forSession(session).buildFullPath(request.getMailboxName());
+        return Mono.from(mailboxManager.createMailboxReactive(mailboxPath, 
session.getMailboxSession()))
+            .flatMap(mailboxId -> unsolicitedResponses(session, responder, 
false)
+                .then(Mono.fromRunnable(() -> okComplete(request, 
StatusResponse.ResponseCode.mailboxId(mailboxId), responder))))
+            .onErrorResume(MailboxExistsException.class, e -> {
+                no(request, responder, HumanReadableText.MAILBOX_EXISTS);
+                return ReactorUtils.logAsMono(() -> LOGGER.debug("Create 
failed for mailbox {} as it already exists", mailboxPath, e));
+            })
+            .onErrorResume(TooLongMailboxNameException.class, e -> {
+                taggedBad(request, responder, 
HumanReadableText.FAILURE_MAILBOX_NAME);
+                return ReactorUtils.logAsMono(() -> LOGGER.debug("The mailbox 
name length is over limit: {}", mailboxPath.getName(), e));
+            })
+            .onErrorResume(TooLongMailboxNameException.class, e -> {
+                no(request, responder, 
HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING);
+                return ReactorUtils.logAsMono(() -> LOGGER.error("Create 
failed for mailbox {}", mailboxPath, e));
+            })
+            .then();
     }
 
     @Override


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

Reply via email to