You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2020/12/11 10:44:15 UTC
[james-project] 11/15: [REFACTORING] StoreMailboxManager: get rid
of nested block call upon mailbox creation
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 49a59ee707139d14bad31e73bf0125700a3ea827
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sun Dec 6 21:41:11 2020 +0700
[REFACTORING] StoreMailboxManager: get rid of nested block call upon mailbox creation
---
.../james/mailbox/store/StoreMailboxManager.java | 32 +++++++++-------------
1 file changed, 13 insertions(+), 19 deletions(-)
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
index 2564f56..aaf25a8 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
@@ -85,7 +85,6 @@ import org.apache.james.mailbox.store.mail.MessageMapper;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.quota.QuotaComponents;
import org.apache.james.mailbox.store.search.MessageSearchIndex;
-import org.apache.james.mailbox.store.transaction.Mapper;
import org.apache.james.mailbox.store.user.SubscriptionMapper;
import org.apache.james.mailbox.store.user.model.Subscription;
import org.apache.james.util.FunctionalUtils;
@@ -376,29 +375,24 @@ public class StoreMailboxManager implements MailboxManager {
locker.executeWithLock(mailboxPath, () ->
block(mapper.pathExists(mailboxPath)
.filter(FunctionalUtils.identityPredicate().negate())
- .flatMap(any -> {
- try {
- mapper.execute(Mapper.toTransaction(() ->
- block(mapper.create(mailboxPath, UidValidity.generate())
- .doOnNext(mailbox -> mailboxIds.add(mailbox.getMailboxId()))
- .flatMap(mailbox ->
- // notify listeners
- eventBus.dispatch(EventFactory.mailboxAdded()
- .randomEventId()
- .mailboxSession(mailboxSession)
- .mailbox(mailbox)
- .build(),
- new MailboxIdRegistrationKey(mailbox.getMailboxId()))))));
- } catch (Exception e) {
+ .flatMap(any -> mapper.executeReactive(mapper.create(mailboxPath, UidValidity.generate())
+ .doOnNext(mailbox -> mailboxIds.add(mailbox.getMailboxId()))
+ .flatMap(mailbox ->
+ // notify listeners
+ eventBus.dispatch(EventFactory.mailboxAdded()
+ .randomEventId()
+ .mailboxSession(mailboxSession)
+ .mailbox(mailbox)
+ .build(),
+ new MailboxIdRegistrationKey(mailbox.getMailboxId()))))
+ .onErrorResume(e -> {
if (e instanceof MailboxExistsException) {
LOGGER.info("{} mailbox was created concurrently", mailboxPath.asString());
} else if (e instanceof MailboxException) {
return Mono.error(e);
}
- }
-
- return Mono.empty();
- })
+ return Mono.empty();
+ }))
.then()), MailboxPathLocker.LockType.Write);
return mailboxIds;
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org