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/06/12 14:24:15 UTC

[james-project] 03/03: [FIX] SystemMailboxesProviderImpl: avoid blocking calls

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 b15b65ed4c5f90cf7ffe0de8a4728b9e135625ee
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Jun 10 13:47:54 2022 +0700

    [FIX] SystemMailboxesProviderImpl: avoid blocking calls
---
 .../apache/james/mailbox/store/SystemMailboxesProviderImpl.java   | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/SystemMailboxesProviderImpl.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/SystemMailboxesProviderImpl.java
index e97e9699dc..3b6a2fbd7c 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/SystemMailboxesProviderImpl.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/SystemMailboxesProviderImpl.java
@@ -35,8 +35,6 @@ import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.search.MailboxQuery;
 import org.apache.james.mailbox.model.search.PrefixedWildcard;
 
-import com.github.fge.lambdas.Throwing;
-import com.github.fge.lambdas.functions.ThrowingFunction;
 import com.google.common.annotations.VisibleForTesting;
 
 import reactor.core.publisher.Flux;
@@ -60,7 +58,6 @@ public class SystemMailboxesProviderImpl implements SystemMailboxesProvider {
         return Mono.from(mailboxManager.getMailboxReactive(mailboxPath, session))
             .flux()
             .onErrorResume(MailboxNotFoundException.class, e -> searchMessageManagerByMailboxRole(aRole, username));
-
     }
 
     private boolean hasRole(Role aRole, MailboxPath mailBoxPath) {
@@ -70,14 +67,13 @@ public class SystemMailboxesProviderImpl implements SystemMailboxesProvider {
     }
 
     private Flux<MessageManager> searchMessageManagerByMailboxRole(Role aRole, Username username) {
-        MailboxSession session = mailboxManager.createSystemSession(username);
-        ThrowingFunction<MailboxPath, MessageManager> loadMailbox = path -> mailboxManager.getMailbox(path, session);
+        MailboxSession session = mailboxManager.createSystemSession(username);;
         MailboxQuery mailboxQuery = MailboxQuery.privateMailboxesBuilder(session)
             .expression(new PrefixedWildcard(aRole.getDefaultMailbox()))
             .build();
         return mailboxManager.search(mailboxQuery, Minimal, session)
             .map(MailboxMetaData::getPath)
             .filter(path -> hasRole(aRole, path))
-            .map(Throwing.function(loadMailbox).sneakyThrow());
+            .concatMap(path -> mailboxManager.getMailboxReactive(path, session));
     }
 }


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