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 2021/06/30 01:07:11 UTC

[james-project] branch master updated (7cff48b -> 223c915)

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

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


    from 7cff48b  JAMES-3576 Fixing mapper tests
     new d960697  [PERFORMANCE] Email/get serialization: initialize DateTimeFormatter once
     new 482e770  [PERFORMANCE] Fasten Mailbox/get by ids
     new dbcdd25  JAMES-3491 WebSocket should unregister resources on cancels
     new 239c408  JAMES-3466 Provision default mailboxes only when listing all mailboxes
     new df97b0c  JAMES-3466 MailboxFactory do not need access to the SubscriptionManager
     new 223c915  JAMES-3171 Mailbox/get by ids was doing some nested .block() calls

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/james/mailbox/MessageManager.java   |  2 +
 .../james/mailbox/store/StoreMessageManager.java   | 13 ++++++
 .../james/jmap/draft/model/MailboxFactory.java     |  7 ++--
 .../contract/MailboxChangesMethodContract.scala    |  3 +-
 .../scala/org/apache/james/jmap/json/package.scala |  4 +-
 .../apache/james/jmap/mail/MailboxFactory.scala    | 17 +++++---
 .../org/apache/james/jmap/mail/MailboxGet.scala    |  4 ++
 .../james/jmap/method/MailboxGetMethod.scala       | 48 ++++++++++++----------
 .../apache/james/jmap/routes/WebSocketRoutes.scala |  3 +-
 9 files changed, 66 insertions(+), 35 deletions(-)

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


[james-project] 03/06: JAMES-3491 WebSocket should unregister resources on cancels

Posted by bt...@apache.org.
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 dbcdd252e3b79ae9654c06db120c4e11ef57675f
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sun Jun 27 13:49:48 2021 +0700

    JAMES-3491 WebSocket should unregister resources on cancels
---
 .../src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala
index 4585a27..16b2241 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/WebSocketRoutes.scala
@@ -33,7 +33,7 @@ import org.apache.james.jmap.HttpConstants.JSON_CONTENT_TYPE
 import org.apache.james.jmap.JMAPUrls.JMAP_WS
 import org.apache.james.jmap.api.change.{EmailChangeRepository, MailboxChangeRepository}
 import org.apache.james.jmap.api.model.{AccountId => JavaAccountId}
-import org.apache.james.jmap.change.{AccountIdRegistrationKey, StateChangeListener, TypeName, _}
+import org.apache.james.jmap.change.{AccountIdRegistrationKey, StateChangeListener, _}
 import org.apache.james.jmap.core.{OutboundMessage, ProblemDetails, RequestId, WebSocketError, WebSocketPushDisable, WebSocketPushEnable, WebSocketRequest, WebSocketResponse, _}
 import org.apache.james.jmap.exceptions.UnauthorizedException
 import org.apache.james.jmap.http.rfc8621.InjectionKeys
@@ -111,6 +111,7 @@ class WebSocketRoutes @Inject() (@Named(InjectionKeys.RFC_8621) val authenticato
       })
       .flatMap(message => handleClientMessages(context)(message))
       .doOnTerminate(context.clean)
+      .doOnCancel(context.clean)
 
     out.sendString(
       SFlux.merge(Seq(responseFlux, sink.asFlux()))

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


[james-project] 05/06: JAMES-3466 MailboxFactory do not need access to the SubscriptionManager

Posted by bt...@apache.org.
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 df97b0c30393397d7cd1a939e64a56a46a0bbcc8
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sun Jun 27 14:02:35 2021 +0700

    JAMES-3466 MailboxFactory do not need access to the SubscriptionManager
---
 .../src/main/scala/org/apache/james/jmap/mail/MailboxFactory.scala      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxFactory.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxFactory.scala
index a932704..d4271cd 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxFactory.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxFactory.scala
@@ -75,7 +75,7 @@ case class Subscriptions(subscribedNames: Set[String]) {
   def isSubscribed(metaData: MailboxMetaData): IsSubscribed = isSubscribed(metaData.getPath.getName)
 }
 
-class MailboxFactory @Inject() (subscriptionManager: SubscriptionManager, mailboxManager: MailboxManager) {
+class MailboxFactory @Inject() (mailboxManager: MailboxManager) {
 
   private def getRole(mailboxPath: MailboxPath, mailboxSession: MailboxSession): Option[Role] = Role.from(mailboxPath.getName)
     .filter(_ => mailboxPath.belongsTo(mailboxSession)).toScala

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


[james-project] 04/06: JAMES-3466 Provision default mailboxes only when listing all mailboxes

Posted by bt...@apache.org.
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 239c4087193142f2239b494e749d275e72326dab
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sun Jun 27 14:02:09 2021 +0700

    JAMES-3466 Provision default mailboxes only when listing all mailboxes
---
 .../contract/MailboxChangesMethodContract.scala    |  3 +-
 .../james/jmap/method/MailboxGetMethod.scala       | 38 +++++++++++-----------
 2 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxChangesMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxChangesMethodContract.scala
index f4cdb93..1c1f40a 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxChangesMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxChangesMethodContract.scala
@@ -1986,8 +1986,7 @@ trait MailboxChangesMethodContract {
          |  "methodCalls": [[
          |    "Mailbox/get",
          |    {
-         |      "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
-         |      "ids": ["$mailboxId"]
+         |      "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6"
          |    },
          |    "c1"]]
          |}""".stripMargin
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala
index 9a62ca9..0354284 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala
@@ -107,28 +107,28 @@ class MailboxGetMethod @Inject() (serializer: MailboxSerializer,
     case errors: JsError => Left(new IllegalArgumentException(ResponseSerializer.serialize(errors).toString))
   }
 
+
   private def getMailboxes(capabilities: Set[CapabilityIdentifier],
                            mailboxGetRequest: MailboxGetRequest,
                            mailboxSession: MailboxSession): SFlux[MailboxGetResults] =
-    provisioner.createMailboxesIfNeeded(mailboxSession)
-      .thenMany(
-        mailboxGetRequest.ids match {
-          case None => getAllMailboxes(capabilities, mailboxSession)
-            .map(MailboxGetResults.found)
-          case Some(Ids.EMPTY) => SFlux.empty
-          case Some(ids) =>
-            SMono.zip(array => (array(0).asInstanceOf[QuotaLoaderWithPreloadedDefault],
-              array(1).asInstanceOf[Subscriptions]),
-              quotaFactory.loadFor(mailboxSession),
-              retrieveSubscriptions(mailboxSession))
-              .flatMapMany {
-                case (quotaLoader, subscriptions) => SFlux.fromIterable(ids.value)
-                  .flatMap(id => Try(mailboxIdFactory.fromString(id.id))
-                    .fold(e => SMono.just(MailboxGetResults.notFound(id)),
-                      mailboxId => getMailboxResultById(capabilities, mailboxId, subscriptions, quotaLoader, mailboxSession)),
-                    maxConcurrency = 5)
-              }
-        })
+    mailboxGetRequest.ids match {
+      case None => provisioner.createMailboxesIfNeeded(mailboxSession)
+        .thenMany(getAllMailboxes(capabilities, mailboxSession))
+        .map(MailboxGetResults.found)
+      case Some(Ids.EMPTY) => SFlux.empty
+      case Some(ids) =>
+        SMono.zip(array => (array(0).asInstanceOf[QuotaLoaderWithPreloadedDefault],
+          array(1).asInstanceOf[Subscriptions]),
+          quotaFactory.loadFor(mailboxSession),
+          retrieveSubscriptions(mailboxSession))
+          .flatMapMany {
+            case (quotaLoader, subscriptions) => SFlux.fromIterable(ids.value)
+              .flatMap(id => Try(mailboxIdFactory.fromString(id.id))
+                .fold(e => SMono.just(MailboxGetResults.notFound(id)),
+                  mailboxId => getMailboxResultById(capabilities, mailboxId, subscriptions, quotaLoader, mailboxSession)),
+                maxConcurrency = 5)
+          }
+    }
 
   private def retrieveSubscriptions(mailboxSession: MailboxSession): SMono[Subscriptions] =
     SFlux(subscriptionManager.subscriptionsReactive(mailboxSession))

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


[james-project] 01/06: [PERFORMANCE] Email/get serialization: initialize DateTimeFormatter once

Posted by bt...@apache.org.
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 d9606971b9bb9fa79c9faef7ed9aa78db429346c
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Jun 26 20:09:49 2021 +0700

    [PERFORMANCE] Email/get serialization: initialize DateTimeFormatter once
---
 .../src/main/scala/org/apache/james/jmap/json/package.scala           | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/package.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/package.scala
index 2fe419f..9219314 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/package.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/package.scala
@@ -93,8 +93,8 @@ package object json {
         mailAddress => JsSuccess(mailAddress))
     case _ => JsError("mail address needs to be represented with a JsString")
   }
-  private[json] implicit val utcDateWrites: Writes[UTCDate] =
-    utcDate => JsString(utcDate.asUTC.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssX")))
+  private val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssX")
+  private[json] implicit val utcDateWrites: Writes[UTCDate] = utcDate => JsString(utcDate.asUTC.format(dateTimeFormatter))
   private[json] implicit val hasMoreChangesWrites: Writes[HasMoreChanges] = Json.valueWrites[HasMoreChanges]
   private[json] implicit val limitReads: Reads[Limit] = {
     case JsNumber(underlying) if underlying > 0 => JsSuccess(Limit.of(underlying.intValue))

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


[james-project] 02/06: [PERFORMANCE] Fasten Mailbox/get by ids

Posted by bt...@apache.org.
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 482e770d97f7e2af8c88cdf0154bd3e5acde9413
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sun Jun 27 12:20:12 2021 +0700

    [PERFORMANCE] Fasten Mailbox/get by ids
    
     - Load quotas only once
    
    Was loaded for each id...
    
     - Shortcut on emtpy Ids
    
    This happens for instance when chaining /changes and /get with backreference.
    
    We can save on subscriptions / quota loading...
---
 .../org/apache/james/jmap/mail/MailboxGet.scala    |  4 +++
 .../james/jmap/method/MailboxGetMethod.scala       | 34 +++++++++++++---------
 2 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxGet.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxGet.scala
index af866cd..2666989 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxGet.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxGet.scala
@@ -47,6 +47,10 @@ object MailboxGet {
 
 case class UnparsedMailboxId(id: Id)
 
+object Ids {
+  val EMPTY = Ids(List())
+}
+
 case class Ids(value: List[UnparsedMailboxId])
 
 case class MailboxGetRequest(accountId: AccountId,
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala
index ca9b2e1..9a62ca9 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala
@@ -28,7 +28,7 @@ import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
 import org.apache.james.jmap.core.{AccountId, CapabilityIdentifier, ErrorCode, Invocation, Properties, UuidState}
 import org.apache.james.jmap.http.MailboxesProvisioner
 import org.apache.james.jmap.json.{MailboxSerializer, ResponseSerializer}
-import org.apache.james.jmap.mail.{Mailbox, MailboxFactory, MailboxGet, MailboxGetRequest, MailboxGetResponse, NotFound, PersonalNamespace, Subscriptions, UnparsedMailboxId}
+import org.apache.james.jmap.mail.{Ids, Mailbox, MailboxFactory, MailboxGet, MailboxGetRequest, MailboxGetResponse, NotFound, PersonalNamespace, Subscriptions, UnparsedMailboxId}
 import org.apache.james.jmap.routes.SessionSupplier
 import org.apache.james.jmap.utils.quotas.{QuotaLoaderWithPreloadedDefault, QuotaLoaderWithPreloadedDefaultFactory}
 import org.apache.james.mailbox.exception.MailboxNotFoundException
@@ -115,13 +115,19 @@ class MailboxGetMethod @Inject() (serializer: MailboxSerializer,
         mailboxGetRequest.ids match {
           case None => getAllMailboxes(capabilities, mailboxSession)
             .map(MailboxGetResults.found)
+          case Some(Ids.EMPTY) => SFlux.empty
           case Some(ids) =>
-            retrieveSubscriptions(mailboxSession)
-              .flatMapMany(subscriptions => SFlux.fromIterable(ids.value)
-                .flatMap(id => Try(mailboxIdFactory.fromString(id.id))
-                  .fold(e => SMono.just(MailboxGetResults.notFound(id)),
-                    mailboxId => getMailboxResultById(capabilities, mailboxId, subscriptions, mailboxSession)),
-                  maxConcurrency = 5))
+            SMono.zip(array => (array(0).asInstanceOf[QuotaLoaderWithPreloadedDefault],
+              array(1).asInstanceOf[Subscriptions]),
+              quotaFactory.loadFor(mailboxSession),
+              retrieveSubscriptions(mailboxSession))
+              .flatMapMany {
+                case (quotaLoader, subscriptions) => SFlux.fromIterable(ids.value)
+                  .flatMap(id => Try(mailboxIdFactory.fromString(id.id))
+                    .fold(e => SMono.just(MailboxGetResults.notFound(id)),
+                      mailboxId => getMailboxResultById(capabilities, mailboxId, subscriptions, quotaLoader, mailboxSession)),
+                    maxConcurrency = 5)
+              }
         })
 
   private def retrieveSubscriptions(mailboxSession: MailboxSession): SMono[Subscriptions] =
@@ -132,14 +138,14 @@ class MailboxGetMethod @Inject() (serializer: MailboxSerializer,
   private def getMailboxResultById(capabilities: Set[CapabilityIdentifier],
                                    mailboxId: MailboxId,
                                    subscriptions: Subscriptions,
+                                   quotaLoader: QuotaLoaderWithPreloadedDefault,
                                    mailboxSession: MailboxSession): SMono[MailboxGetResults] =
-    quotaFactory.loadFor(mailboxSession)
-      .flatMap(quotaLoader => mailboxFactory.create(mailboxId, mailboxSession, quotaLoader, subscriptions)
-        .map(mailbox => filterShared(capabilities, mailbox))
-        .onErrorResume {
-          case _: MailboxNotFoundException => SMono.just(MailboxGetResults.notFound(mailboxId))
-          case error => SMono.error(error)
-        })
+    mailboxFactory.create(mailboxId, mailboxSession, quotaLoader, subscriptions)
+      .map(mailbox => filterShared(capabilities, mailbox))
+      .onErrorResume {
+        case _: MailboxNotFoundException => SMono.just(MailboxGetResults.notFound(mailboxId))
+        case error => SMono.error(error)
+      }
       .subscribeOn(Schedulers.elastic)
 
   private def filterShared(capabilities: Set[CapabilityIdentifier], mailbox: Mailbox): MailboxGetResults = {

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


[james-project] 06/06: JAMES-3171 Mailbox/get by ids was doing some nested .block() calls

Posted by bt...@apache.org.
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 223c9159487d6a0a8d12172d28de5496ddd042ef
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Jun 29 09:32:25 2021 +0700

    JAMES-3171 Mailbox/get by ids was doing some nested .block() calls
---
 .../java/org/apache/james/mailbox/MessageManager.java     |  2 ++
 .../apache/james/mailbox/store/StoreMessageManager.java   | 13 +++++++++++++
 .../org/apache/james/jmap/draft/model/MailboxFactory.java |  7 +++----
 .../scala/org/apache/james/jmap/mail/MailboxFactory.scala | 15 +++++++++++----
 4 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MessageManager.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MessageManager.java
index e214865..70cc309 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MessageManager.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MessageManager.java
@@ -85,6 +85,8 @@ public interface MessageManager {
      */
     MailboxCounters getMailboxCounters(MailboxSession mailboxSession) throws MailboxException;
 
+    Publisher<MailboxCounters> getMailboxCountersReactive(MailboxSession mailboxSession);
+
     /**
      * Return if the Mailbox is writable
      * @deprecated use
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
index 4487e8d..f22323d 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
@@ -227,6 +227,19 @@ public class StoreMessageManager implements MessageManager {
             .build();
     }
 
+
+    @Override
+    public Publisher<MailboxCounters> getMailboxCountersReactive(MailboxSession mailboxSession) {
+        if (storeRightManager.hasRight(mailbox, MailboxACL.Right.Read, mailboxSession)) {
+            return mapperFactory.createMessageMapper(mailboxSession).getMailboxCountersReactive(mailbox);
+        }
+        return Mono.just(MailboxCounters.builder()
+            .mailboxId(mailbox.getMailboxId())
+            .count(0)
+            .unseen(0)
+            .build());
+    }
+
     /**
      * Returns the flags which are shared for the current mailbox, i.e. the
      * flags set up so that changes to those flags are visible to another user.
diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/MailboxFactory.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/MailboxFactory.java
index 7f3f723..8b0ba9c 100644
--- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/MailboxFactory.java
+++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/MailboxFactory.java
@@ -50,7 +50,6 @@ import com.google.common.base.Splitter;
 import com.google.common.primitives.Booleans;
 
 import reactor.core.publisher.Mono;
-import reactor.core.scheduler.Schedulers;
 
 public class MailboxFactory {
     private static class MailboxTuple {
@@ -59,9 +58,9 @@ public class MailboxFactory {
         }
 
         public static Mono<MailboxTuple> from(MessageManager messageManager, MailboxSession session) {
-            return Mono.fromCallable(() ->
-                new MailboxTuple(messageManager.getMailboxPath(), messageManager.getMailboxCounters(session).sanitize(), messageManager.getResolvedAcl(session)))
-                .subscribeOn(Schedulers.elastic());
+            return Mono.from(messageManager.getMailboxCountersReactive(session))
+                .map(MailboxCounters::sanitize)
+                .map(Throwing.function(counters -> new MailboxTuple(messageManager.getMailboxPath(), counters, messageManager.getResolvedAcl(session))));
         }
 
         private final MailboxPath mailboxPath;
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxFactory.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxFactory.scala
index d4271cd..b235082 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxFactory.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxFactory.scala
@@ -160,11 +160,18 @@ class MailboxFactory @Inject() (mailboxManager: MailboxManager) {
     }
   }
 
-  def create(id: MailboxId, mailboxSession: MailboxSession, quotaLoader: QuotaLoader, subscriptions: Subscriptions): SMono[Mailbox] = {
-    try {
-      val messageManager: MessageManager = mailboxManager.getMailbox(id, mailboxSession)
-      val sanitizedCounters: MailboxCounters = messageManager.getMailboxCounters(mailboxSession).sanitize()
+  def create(id: MailboxId, mailboxSession: MailboxSession, quotaLoader: QuotaLoader, subscriptions: Subscriptions): SMono[Mailbox] =
+    for {
+      messageManager <- SMono(mailboxManager.getMailboxReactive(id, mailboxSession))
+      counters <- SMono(messageManager.getMailboxCountersReactive(mailboxSession))
+      sanitizedCounters = counters.sanitize()
+      mailbox <- instanciateMailbox(id, mailboxSession, quotaLoader, messageManager, sanitizedCounters, subscriptions)
+    } yield {
+      mailbox
+    }
 
+  private def instanciateMailbox(id: MailboxId, mailboxSession: MailboxSession, quotaLoader: QuotaLoader, messageManager: MessageManager, sanitizedCounters: MailboxCounters, subscriptions: Subscriptions): SMono[Mailbox] = {
+    try {
       MailboxValidation.validate(messageManager.getMailboxPath, mailboxSession.getPathDelimiter, sanitizedCounters.getUnseen, sanitizedCounters.getUnseen, sanitizedCounters.getCount, sanitizedCounters.getCount) match {
         case Left(error) => SMono.error(error)
         case scala.Right(mailboxValidation) =>

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