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:04 UTC

[james-project] branch master updated (0ade633 -> de85e69)

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

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


    from 0ade633  JAMES-3440 Fix Iterators.toFlux call
     new 282bfcb  JAMES-3435 Add missing event store module for CassandraMailboxMapperConcurrencyTest
     new a0c87b7  JAMES-2884 Mandate core specification
     new f43a558  JAMES-2578 No longer rely on Java serialization for JMS and ActiveMQ
     new 56e7f67  JAMES-2578 PerRecipientHeaders: No longer rely on Java serialization for JMS and ActiveMQ
     new 4c0f894  JAMES-2578 Remove SerializationUtil
     new ac24814  JAMES-2578 Document upgrade-instructions
     new 7433248  JAMES-2543 minor cleanups that slipped review
     new 81b8cc9  [REFACTORING] Use default methods in Mapper interface
     new 0b2b11e  [REFACTORING] StoreMailboxManager: limit visibility of getters where possible
     new 442a556  [REFACTORING] StoreMailboxManager: little code style enhencements
     new 49a59ee  [REFACTORING] StoreMailboxManager: get rid of nested block call upon mailbox creation
     new 1181b78  [REFACTORING] Remove Mapper::executeReactiveVoid
     new 9386502  [REFACTORING] Remove unused MailboxIdDeserializer class
     new c208e8b  [REFACTORING] FlagsExtractor can be static
     new de85e69  [REFACTORING] Use StandardCharsets in more places

The 15 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:
 .../ids/CassandraMailboxIdDeserializer.java        |  38 --------
 .../cassandra/mail/CassandraAnnotationMapper.java  |   4 -
 .../cassandra/mail/CassandraApplicableFlagDAO.java |   2 +-
 .../cassandra/mail/CassandraAttachmentMapper.java  |   9 --
 .../cassandra/mail/CassandraMailboxMapper.java     |  11 ---
 .../cassandra/mail/CassandraMessageIdDAO.java      |   2 +-
 .../mail/CassandraMessageIdToImapUidDAO.java       |   2 +-
 .../cassandra/mail/CassandraMessageMapper.java     |  10 --
 .../mailbox/cassandra/mail/FlagsExtractor.java     |  11 +--
 .../user/CassandraSubscriptionMapper.java          |   6 --
 .../ids/CassandraMailboxIdDeserializerTest.java    |  55 -----------
 .../CassandraMailboxMapperConcurrencyTest.java     |   4 +-
 .../mailbox/jpa/JPAMailboxIdDeserializer.java      |  35 -------
 .../main/resources/META-INF/spring/mailbox-jpa.xml |   2 -
 .../mailbox/jpa/JPAMailboxIdDeserializerTest.java  |  53 -----------
 .../jpa/mail/TransactionalAnnotationMapper.java    |  11 ---
 .../jpa/mail/TransactionalMailboxMapper.java       |  13 +--
 .../jpa/mail/TransactionalMessageMapper.java       |  11 ---
 .../maildir/MaildirMailboxIdDeserializer.java      |  35 -------
 .../mailbox/maildir/mail/MaildirMailboxMapper.java |   5 -
 .../mailbox/maildir/mail/MaildirMessageMapper.java |   6 --
 .../maildir/user/MaildirSubscriptionMapper.java    |   6 --
 .../resources/META-INF/spring/mailbox-maildir.xml  |   2 -
 .../maildir/MaildirMailboxIdDeserializerTest.java  |  56 -----------
 .../inmemory/InMemoryMailboxIdDeserializer.java    |  36 -------
 .../inmemory/mail/InMemoryAnnotationMapper.java    |  11 ---
 .../inmemory/mail/InMemoryAttachmentMapper.java    |  10 --
 .../inmemory/mail/InMemoryMailboxMapper.java       |  11 ---
 .../inmemory/mail/InMemoryMessageMapper.java       |   5 -
 .../inmemory/mail/InMemoryModSeqProvider.java      |   1 -
 .../inmemory/user/InMemorySubscriptionMapper.java  |   6 --
 .../resources/META-INF/spring/mailbox-memory.xml   |   2 -
 .../InMemoryMailboxIdDeserializerTest.java         |  54 -----------
 .../james/mailbox/store/StoreMailboxManager.java   |  48 ++++------
 .../store/mail/model/MailboxIdDeserializer.java    |  28 ------
 .../james/mailbox/store/search/SearchUtil.java     |  12 +--
 .../james/mailbox/store/transaction/Mapper.java    |  14 ++-
 .../store/transaction/NonTransactionalMapper.java  |   7 --
 .../store/transaction/TransactionalMapper.java     |   9 +-
 .../PartContentBuilderComplexMultipartTest.java    |   3 +-
 ...PartContentBuilderMultipartAlternativeTest.java |   7 +-
 .../StoreMailboxMessageResultIteratorTest.java     |  15 +--
 .../search/SearchUtilsMultipartMixedTest.java      |   4 +-
 .../store/search/SearchUtilsRFC822Test.java        |   4 +-
 .../org/apache/mailet/PerRecipientHeaders.java     |  36 ++++++-
 .../james/mpt/helper/ByteBufferInputStream.java    |   4 +-
 .../james/mpt/helper/ByteBufferOutputStream.java   |   8 +-
 .../org/apache/james/mpt/helper/ScriptBuilder.java |   7 +-
 .../apache/james/mpt/session/ExternalSession.java  |  10 +-
 .../java/org/apache/james/mpt/DiscardProtocol.java |   8 +-
 .../james/mpt/smtp/SmtpStarttlsCommandTest.java    |   2 +-
 .../james/protocols/api/ProtocolSessionImpl.java   |   5 +-
 .../james/imap/decode/ImapRequestLineReader.java   |   4 +-
 .../imap/encode/base/ImapResponseComposerImpl.java |   8 +-
 .../imap/processor/AuthenticateProcessor.java      |   4 +-
 .../parser/SearchCommandParserCharsetTest.java     |  33 +++----
 .../org/apache/james/CassandraNodeConfTest.java    |   4 +-
 .../james/JamesServerWithRetryConnectionTest.java  |   4 +-
 .../CassandraSchemaVersionStartUpCheckTest.java    |   4 +-
 .../java/org/apache/james/JamesServerContract.java |   4 +-
 .../java/org/apache/james/JPAJamesServerTest.java  |   4 +-
 .../java/org/apache/james/JPAJamesServerTest.java  |   4 +-
 .../org/apache/james/util/SerializationUtil.java   |  64 -------------
 .../apache/james/util/SerializationUtilTest.java   | 106 ---------------------
 .../jmap/rfc8621/contract/EchoMethodContract.scala |  21 ++--
 .../rfc8621/contract/EmailGetMethodContract.scala  |   2 +-
 .../rfc8621/contract/IdentityGetContract.scala     |  14 +--
 .../contract/MailboxGetMethodContract.scala        |   6 +-
 .../contract/MailboxSetMethodContract.scala        |   6 +-
 .../VacationResponseGetMethodContract.scala        |   2 +-
 .../VacationResponseSetMethodContract.scala        |   2 +-
 .../apache/james/jmap/method/CoreEchoMethod.scala  |   4 +-
 .../apache/james/jmap/method/EmailGetMethod.scala  |   4 +-
 .../james/jmap/method/EmailQueryMethod.scala       |   4 +-
 .../apache/james/jmap/method/EmailSetMethod.scala  |   4 +-
 .../jmap/method/EmailSubmissionSetMethod.scala     |   4 +-
 .../james/jmap/method/IdentityGetMethod.scala      |   4 +-
 .../james/jmap/method/MailboxGetMethod.scala       |   4 +-
 .../james/jmap/method/MailboxQueryMethod.scala     |   4 +-
 .../james/jmap/method/MailboxSetMethod.scala       |   4 +-
 .../apache/james/jmap/method/ThreadGetMethod.scala |   4 +-
 .../jmap/method/VacationResponseGetMethod.scala    |   4 +-
 .../jmap/method/VacationResponseSetMethod.scala    |   4 +-
 .../queue/activemq/ActiveMQMailQueueBlobTest.java  |   6 --
 .../queue/activemq/ActiveMQMailQueueTest.java      |   6 --
 .../james/queue/jms/JMSCacheableMailQueue.java     |  48 +++++++---
 .../james/queue/jms/JMSCacheableMailQueueTest.java |   6 --
 .../org/apache/james/utils/FakeSmtpExtension.java  |   2 +-
 upgrade-instructions.md                            |  21 ++++
 89 files changed, 248 insertions(+), 941 deletions(-)
 delete mode 100644 mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/ids/CassandraMailboxIdDeserializer.java
 delete mode 100644 mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/ids/CassandraMailboxIdDeserializerTest.java
 delete mode 100644 mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxIdDeserializer.java
 delete mode 100644 mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxIdDeserializerTest.java
 delete mode 100644 mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxIdDeserializer.java
 delete mode 100644 mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxIdDeserializerTest.java
 delete mode 100644 mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxIdDeserializer.java
 delete mode 100644 mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxIdDeserializerTest.java
 delete mode 100644 mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxIdDeserializer.java
 delete mode 100644 server/container/util/src/main/java/org/apache/james/util/SerializationUtil.java
 delete mode 100644 server/container/util/src/test/java/org/apache/james/util/SerializationUtilTest.java


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


[james-project] 01/15: JAMES-3435 Add missing event store module for CassandraMailboxMapperConcurrencyTest

Posted by rc...@apache.org.
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 282bfcb437b25a0c384f8bb00e09003cf8c7a34a
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 10 17:49:46 2020 +0700

    JAMES-3435 Add missing event store module for CassandraMailboxMapperConcurrencyTest
    
    Now that ACLs rely on event store, it's necessary to include it in tests using Cassandra ACL module.
---
 .../mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java
index 70fc8b0..8c896db 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java
@@ -30,6 +30,7 @@ import org.apache.james.backends.cassandra.components.CassandraModule;
 import org.apache.james.backends.cassandra.versions.CassandraSchemaVersionModule;
 import org.apache.james.blob.cassandra.CassandraBlobModule;
 import org.apache.james.core.Username;
+import org.apache.james.eventsourcing.eventstore.cassandra.CassandraEventStoreModule;
 import org.apache.james.mailbox.cassandra.mail.utils.GuiceUtils;
 import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
@@ -54,7 +55,8 @@ class CassandraMailboxMapperConcurrencyTest {
             CassandraBlobModule.MODULE,
             CassandraSchemaVersionModule.MODULE,
             CassandraMailboxModule.MODULE,
-            CassandraAclModule.MODULE));
+            CassandraAclModule.MODULE,
+            CassandraEventStoreModule.MODULE()));
 
     private CassandraMailboxMapper testee;
 


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


[james-project] 12/15: [REFACTORING] Remove Mapper::executeReactiveVoid

Posted by rc...@apache.org.
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 1181b78c75a1e8b8d1970c8d59b679d02dafa17d
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sun Dec 6 21:47:00 2020 +0700

    [REFACTORING] Remove Mapper::executeReactiveVoid
---
 .../apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java  | 2 +-
 .../james/mailbox/store/transaction/TransactionalMapper.java       | 7 -------
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
index d3ebc16..eef06de 100644
--- a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
+++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
@@ -52,7 +52,7 @@ public class TransactionalMailboxMapper implements MailboxMapper {
 
     @Override
     public Mono<Void> delete(Mailbox mailbox) {
-        return wrapped.executeReactiveVoid(wrapped.delete(mailbox));
+        return wrapped.executeReactive(wrapped.delete(mailbox));
     }
 
     @Override
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/TransactionalMapper.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/TransactionalMapper.java
index 4bc1073..bdfb6d7 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/TransactionalMapper.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/TransactionalMapper.java
@@ -51,13 +51,6 @@ public abstract class TransactionalMapper implements Mapper {
             .doOnError(MailboxException.class, Throwing.consumer(e -> rollback()).sneakyThrow());
     }
 
-    public final Mono<Void> executeReactiveVoid(Mono<Void> transaction) {
-        return Mono.fromRunnable(Throwing.runnable(this::begin).sneakyThrow())
-                .then(transaction)
-                .thenEmpty(Mono.fromRunnable(Throwing.runnable(this::commit).sneakyThrow()))
-                .doOnError(MailboxException.class, Throwing.consumer(e -> rollback()).sneakyThrow());
-    }
-
     /**
      * Begin transaction
      */


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


[james-project] 10/15: [REFACTORING] StoreMailboxManager: little code style enhencements

Posted by rc...@apache.org.
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 442a556d098dbb4326c291eec2fca581cc3aba8e
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sun Dec 6 21:37:49 2020 +0700

    [REFACTORING] StoreMailboxManager: little code style enhencements
---
 .../org/apache/james/mailbox/store/StoreMailboxManager.java    | 10 +++++-----
 1 file changed, 5 insertions(+), 5 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 ddf6b07..2564f56 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
@@ -299,7 +299,7 @@ public class StoreMailboxManager implements MailboxManager {
         return createMessageManager(mailboxRow, session);
     }
 
-    private boolean assertUserHasAccessTo(Mailbox mailbox, MailboxSession session) throws MailboxException {
+    private boolean assertUserHasAccessTo(Mailbox mailbox, MailboxSession session) {
         return belongsToCurrentUser(mailbox, session) || userHasLookupRightsOn(mailbox, session);
     }
 
@@ -307,7 +307,7 @@ public class StoreMailboxManager implements MailboxManager {
         return mailbox.generateAssociatedPath().belongsTo(session);
     }
 
-    private boolean userHasLookupRightsOn(Mailbox mailbox, MailboxSession session) throws MailboxException {
+    private boolean userHasLookupRightsOn(Mailbox mailbox, MailboxSession session) {
         return storeRightManager.hasRight(mailbox, Right.Lookup, session);
     }
 
@@ -372,11 +372,11 @@ public class StoreMailboxManager implements MailboxManager {
 
     private List<MailboxId> performConcurrentMailboxCreation(MailboxSession mailboxSession, MailboxPath mailboxPath) throws MailboxException {
         List<MailboxId> mailboxIds = new ArrayList<>();
+        MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(mailboxSession);
         locker.executeWithLock(mailboxPath, () ->
-            block(mailboxExists(mailboxPath, mailboxSession)
+            block(mapper.pathExists(mailboxPath)
                 .filter(FunctionalUtils.identityPredicate().negate())
-                .map(Throwing.<Boolean, MailboxMapper>function(ignored -> mailboxSessionMapperFactory.getMailboxMapper(mailboxSession)).sneakyThrow())
-                .flatMap(mapper -> {
+                .flatMap(any -> {
                     try {
                         mapper.execute(Mapper.toTransaction(() ->
                             block(mapper.create(mailboxPath, UidValidity.generate())


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


[james-project] 04/15: JAMES-2578 PerRecipientHeaders: No longer rely on Java serialization for JMS and ActiveMQ

Posted by rc...@apache.org.
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 56e7f67f83d2d196c1f6209727f14911c9fb9e17
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Dec 7 14:19:47 2020 +0700

    JAMES-2578 PerRecipientHeaders: No longer rely on Java serialization for JMS and ActiveMQ
---
 .../org/apache/mailet/PerRecipientHeaders.java     | 36 +++++++++++++++++---
 .../james/queue/jms/JMSCacheableMailQueue.java     | 39 +++++++++++++++++-----
 2 files changed, 61 insertions(+), 14 deletions(-)

diff --git a/mailet/api/src/main/java/org/apache/mailet/PerRecipientHeaders.java b/mailet/api/src/main/java/org/apache/mailet/PerRecipientHeaders.java
index 4e0a434..0f70335 100644
--- a/mailet/api/src/main/java/org/apache/mailet/PerRecipientHeaders.java
+++ b/mailet/api/src/main/java/org/apache/mailet/PerRecipientHeaders.java
@@ -21,14 +21,17 @@ package org.apache.mailet;
 
 import java.io.Serializable;
 import java.util.Collection;
+import java.util.List;
 
 import org.apache.james.core.MailAddress;
 
 import com.github.steveash.guavate.Guavate;
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Joiner;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
+import com.google.common.base.Splitter;
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.Multimap;
 
@@ -74,12 +77,8 @@ public class PerRecipientHeaders implements Serializable {
     }
 
     public static class Header implements Serializable {
-        private final String name;
-        private final String value;
 
-        public static Builder builder() {
-            return new Builder();
-        }
+        public static final String SEPARATOR = ": ";
 
         public static class Builder {
             private String name;
@@ -102,8 +101,31 @@ public class PerRecipientHeaders implements Serializable {
             }
         }
 
+        public static Builder builder() {
+            return new Builder();
+        }
+
+        public static Header fromString(String value) {
+            Preconditions.checkArgument(value.contains(SEPARATOR), "Header is string form needs to contain ': ' separator");
+
+            List<String> parts = Splitter.on(SEPARATOR).splitToList(value);
+
+            return new Header(
+                parts.get(0),
+                Joiner.on(SEPARATOR)
+                    .join(parts.stream()
+                        .skip(1)
+                        .collect(Guavate.toImmutableList())));
+        }
+
+        private final String name;
+        private final String value;
+
         @VisibleForTesting
         Header(String name, String value) {
+            Preconditions.checkArgument(!name.contains(":"), "Header name should not contain separator");
+            Preconditions.checkArgument(!name.contains("\n"), "Header name should not contain line break");
+
             this.name = name;
             this.value = value;
         }
@@ -116,6 +138,10 @@ public class PerRecipientHeaders implements Serializable {
             return value;
         }
 
+        public String asString() {
+            return name + SEPARATOR + value;
+        }
+
         @Override
         public final boolean equals(Object o) {
             if (o instanceof Header) {
diff --git a/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java b/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java
index e6950c7..a680e2c 100644
--- a/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java
+++ b/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java
@@ -32,7 +32,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
-import java.util.Optional;
 import java.util.StringTokenizer;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Stream;
@@ -53,6 +52,7 @@ import javax.mail.internet.AddressException;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.commons.collections.iterators.EnumerationIterator;
+import org.apache.commons.lang3.tuple.Pair;
 import org.apache.james.core.MailAddress;
 import org.apache.james.core.MaybeSender;
 import org.apache.james.lifecycle.api.Disposable;
@@ -68,7 +68,6 @@ import org.apache.james.queue.api.MailQueueName;
 import org.apache.james.queue.api.ManageableMailQueue;
 import org.apache.james.server.core.MailImpl;
 import org.apache.james.server.core.MimeMessageCopyOnWriteProxy;
-import org.apache.james.util.SerializationUtil;
 import org.apache.mailet.Attribute;
 import org.apache.mailet.AttributeName;
 import org.apache.mailet.AttributeUtils;
@@ -341,11 +340,13 @@ public class JMSCacheableMailQueue implements ManageableMailQueue, JMSSupport, M
         props.put(JAMES_MAIL_MESSAGE_SIZE, mail.getMessageSize());
         props.put(JAMES_MAIL_NAME, mail.getName());
 
-        // won't serialize the empty headers so it is mandatory
-        // to handle nulls when reconstructing mail from message
-        if (!mail.getPerRecipientSpecificHeaders().getHeadersByRecipient().isEmpty()) {
-            props.put(JAMES_MAIL_PER_RECIPIENT_HEADERS, SerializationUtil.serialize(mail.getPerRecipientSpecificHeaders()));
-        }
+        mail.getPerRecipientSpecificHeaders().getHeadersByRecipient()
+            .asMap()
+            .forEach((recipient, headers) -> props.put(JAMES_MAIL_PER_RECIPIENT_HEADERS + "-" + recipient.asString(),
+                Joiner.on('\n')
+                    .join(headers.stream()
+                        .map(PerRecipientHeaders.Header::asString)
+                        .collect(Guavate.toImmutableList()))));
 
         String recipientsAsString = joiner.join(mail.getRecipients());
 
@@ -413,9 +414,29 @@ public class JMSCacheableMailQueue implements ManageableMailQueue, JMSSupport, M
         MailImpl.Builder builder = MailImpl.builder().name(name);
         builder.errorMessage(message.getStringProperty(JAMES_MAIL_ERROR_MESSAGE));
         builder.lastUpdated(new Date(message.getLongProperty(JAMES_MAIL_LAST_UPDATED)));
+        Enumeration<String> properties = message.getPropertyNames();
 
-        Optional.ofNullable(SerializationUtil.<PerRecipientHeaders>deserialize(message.getStringProperty(JAMES_MAIL_PER_RECIPIENT_HEADERS)))
-                .ifPresent(builder::addAllHeadersForRecipients);
+        PerRecipientHeaders perRecipientHeaders = new PerRecipientHeaders();
+        ImmutableList.copyOf(properties.asIterator())
+            .stream()
+            .filter(property -> property.startsWith(JAMES_MAIL_PER_RECIPIENT_HEADERS + "-"))
+            .flatMap(property -> {
+                try {
+                    MailAddress address = new MailAddress(property.substring(JAMES_MAIL_PER_RECIPIENT_HEADERS.length() + 1));
+                    String headers = message.getStringProperty(property);
+                    return Splitter.on('\n').splitToList(headers)
+                        .stream()
+                        .map(PerRecipientHeaders.Header::fromString)
+                        .map(header -> Pair.of(address, header));
+                } catch (AddressException | JMSException e) {
+                    LOGGER.error("Error deserializing per-recipient header", e);
+                    return Stream.empty();
+                }
+            })
+            .forEach(pair -> perRecipientHeaders.addHeaderForRecipient(pair.getValue(), pair.getKey()));
+        if (!perRecipientHeaders.getHeadersByRecipient().isEmpty()) {
+            builder.addAllHeadersForRecipients(perRecipientHeaders);
+        }
 
         String recipients = message.getStringProperty(JAMES_MAIL_RECIPIENTS);
         StringTokenizer recipientTokenizer = new StringTokenizer(recipients, JAMES_MAIL_SEPARATOR);


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


[james-project] 14/15: [REFACTORING] FlagsExtractor can be static

Posted by rc...@apache.org.
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 c208e8bb99ab089aba203fc744641ece57f9e770
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sun Dec 6 22:11:36 2020 +0700

    [REFACTORING] FlagsExtractor can be static
---
 .../mailbox/cassandra/mail/CassandraApplicableFlagDAO.java    |  2 +-
 .../james/mailbox/cassandra/mail/CassandraMessageIdDAO.java   |  2 +-
 .../cassandra/mail/CassandraMessageIdToImapUidDAO.java        |  2 +-
 .../apache/james/mailbox/cassandra/mail/FlagsExtractor.java   | 11 ++---------
 4 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraApplicableFlagDAO.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraApplicableFlagDAO.java
index 2fdb846..26eaa6b 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraApplicableFlagDAO.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraApplicableFlagDAO.java
@@ -80,7 +80,7 @@ public class CassandraApplicableFlagDAO {
         return cassandraAsyncExecutor.executeSingleRow(
             select.bind()
                 .setUUID(MAILBOX_ID, mailboxId.asUuid()))
-            .map(row -> new FlagsExtractor(row).getApplicableFlags());
+            .map(FlagsExtractor::getApplicableFlags);
     }
 
     public Mono<Void> updateApplicableFlags(CassandraId cassandraId, Set<String> toBeAdded) {
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdDAO.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdDAO.java
index 2574ed1..6d7f6bc 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdDAO.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdDAO.java
@@ -335,7 +335,7 @@ public class CassandraMessageIdDAO {
                         CassandraId.of(row.getUUID(MAILBOX_ID)),
                         messageIdFactory.of(row.getUUID(MESSAGE_ID)),
                         MessageUid.of(row.getLong(IMAP_UID))))
-                .flags(new FlagsExtractor(row).getFlags())
+                .flags(FlagsExtractor.getFlags(row))
                 .modSeq(ModSeq.of(row.getLong(MOD_SEQ)))
                 .build();
     }
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdToImapUidDAO.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdToImapUidDAO.java
index e12e2de..4c6ee7c 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdToImapUidDAO.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdToImapUidDAO.java
@@ -214,7 +214,7 @@ public class CassandraMessageIdToImapUidDAO {
                     CassandraId.of(row.getUUID(MAILBOX_ID)),
                     messageIdFactory.of(row.getUUID(MESSAGE_ID)),
                     MessageUid.of(row.getLong(IMAP_UID))))
-                .flags(new FlagsExtractor(row).getFlags())
+                .flags(FlagsExtractor.getFlags(row))
                 .modSeq(ModSeq.of(row.getLong(MOD_SEQ)))
                 .build();
     }
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/FlagsExtractor.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/FlagsExtractor.java
index 873e438..c18d37c 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/FlagsExtractor.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/FlagsExtractor.java
@@ -25,14 +25,7 @@ import org.apache.james.mailbox.cassandra.table.Flag;
 import com.datastax.driver.core.Row;
 
 public class FlagsExtractor {
-
-    private final Row row;
-
-    public FlagsExtractor(Row row) {
-        this.row = row;
-    }
-
-    public Flags getFlags() {
+    public static Flags getFlags(Row row) {
         Flags flags = new Flags();
         for (String flag : Flag.ALL) {
             if (row.getBool(flag)) {
@@ -44,7 +37,7 @@ public class FlagsExtractor {
         return flags;
     }
 
-    public Flags getApplicableFlags() {
+    public static Flags getApplicableFlags(Row row) {
         Flags flags = new Flags();
         row.getSet(Flag.USER_FLAGS, String.class)
             .forEach(flags::add);


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


[james-project] 15/15: [REFACTORING] Use StandardCharsets in more places

Posted by rc...@apache.org.
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 de85e69d2908d18bbc5680ff1af8a71742629afe
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sun Dec 6 22:32:50 2020 +0700

    [REFACTORING] Use StandardCharsets in more places
---
 .../james/mailbox/store/search/SearchUtil.java     | 12 ++++----
 .../PartContentBuilderComplexMultipartTest.java    |  3 +-
 ...PartContentBuilderMultipartAlternativeTest.java |  7 ++---
 .../search/SearchUtilsMultipartMixedTest.java      |  4 +--
 .../store/search/SearchUtilsRFC822Test.java        |  4 +--
 .../james/mpt/helper/ByteBufferInputStream.java    |  4 +--
 .../james/mpt/helper/ByteBufferOutputStream.java   |  8 +++---
 .../org/apache/james/mpt/helper/ScriptBuilder.java |  7 ++---
 .../apache/james/mpt/session/ExternalSession.java  | 10 +++----
 .../java/org/apache/james/mpt/DiscardProtocol.java |  8 ++----
 .../james/protocols/api/ProtocolSessionImpl.java   |  5 ++--
 .../james/imap/decode/ImapRequestLineReader.java   |  4 +--
 .../imap/encode/base/ImapResponseComposerImpl.java |  8 ++----
 .../imap/processor/AuthenticateProcessor.java      |  4 +--
 .../parser/SearchCommandParserCharsetTest.java     | 33 +++++++++-------------
 .../org/apache/james/CassandraNodeConfTest.java    |  4 +--
 .../james/JamesServerWithRetryConnectionTest.java  |  4 +--
 .../CassandraSchemaVersionStartUpCheckTest.java    |  4 +--
 .../java/org/apache/james/JamesServerContract.java |  4 +--
 .../java/org/apache/james/JPAJamesServerTest.java  |  4 +--
 .../java/org/apache/james/JPAJamesServerTest.java  |  4 +--
 21 files changed, 65 insertions(+), 80 deletions(-)

diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SearchUtil.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SearchUtil.java
index 4f28090..cb2fc47 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SearchUtil.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SearchUtil.java
@@ -18,7 +18,8 @@
  ****************************************************************/
 package org.apache.james.mailbox.store.search;
 
-import java.nio.charset.Charset;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.util.HashSet;
 import java.util.Locale;
 import java.util.Set;
@@ -52,18 +53,15 @@ public class SearchUtil {
     private static final char CLOSE_SQUARE_BRACKED = ']';
     private static final char COLON = ':';
     
-    private static final Charset UTF8 = Charset.forName("UTF8");
-
-    
     /**
      * Return the DISPLAY ADDRESS for the given {@link Mailbox}. 
      * 
      * See rfc5957 3. DISPLAY Sort Value for an Address for the details
-     * 
+     *
      *     For the purposes of the sort criteria defined in this document, the
      *     sort value for an [IMAP] address structure is defined as follows:
      * <p>
-     *      o If the address structure's [IMAP] addr-name is non-NIL, apply the 
+     *      o If the address structure's [IMAP] addr-name is non-NIL, apply the
      *        procedure from [RFC5255], Section 4.6.  (That is, decode any
      *        RFC2047] encoded-words and convert the resulting character string
      *        into a charset valid for the currently active [RFC4790] collation,
@@ -234,7 +232,7 @@ public class SearchUtil {
             //    Convert all tabs and continuations to space.  Convert all
             //    multiple spaces to a single space.
             String decodedSubject = MimeUtil.unfold(DecoderUtil.decodeEncodedWords(subject, DecodeMonitor.SILENT));
-            decodedSubject = new String(decodedSubject.getBytes(UTF8), UTF8);
+            decodedSubject = new String(decodedSubject.getBytes(UTF_8), UTF_8);
 
             // replace all tabs with spaces and replace multiple spaces with one space
             decodedSubject = decodedSubject.replaceAll("\t", " ").replaceAll("( ){2,}", " ");
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderComplexMultipartTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderComplexMultipartTest.java
index d2d34ce..88e30d3 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderComplexMultipartTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderComplexMultipartTest.java
@@ -24,7 +24,6 @@ import static org.assertj.core.api.Fail.fail;
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
-import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
 
@@ -215,7 +214,7 @@ class PartContentBuilderComplexMultipartTest {
     }
 
     private void to(int[] path) throws Exception {
-        InputStream in = new ByteArrayInputStream(Charset.forName("us-ascii")
+        InputStream in = new ByteArrayInputStream(StandardCharsets.US_ASCII
                 .encode(MULTIPART_MIXED).array());
         builder.parse(in);
         for (int aPath : path) {
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderMultipartAlternativeTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderMultipartAlternativeTest.java
index 813c039..08aae12 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderMultipartAlternativeTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderMultipartAlternativeTest.java
@@ -23,7 +23,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
-import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
 
@@ -101,7 +100,7 @@ class PartContentBuilderMultipartAlternativeTest {
     }
 
     private String fullContent(String mail, int position) throws Exception {
-        InputStream in = new ByteArrayInputStream(Charset.forName("us-ascii")
+        InputStream in = new ByteArrayInputStream(StandardCharsets.US_ASCII
                 .encode(mail).array());
         builder.parse(in);
         builder.to(position);
@@ -109,7 +108,7 @@ class PartContentBuilderMultipartAlternativeTest {
     }
 
     private String bodyContent(String mail, int position) throws Exception {
-        InputStream in = new ByteArrayInputStream(Charset.forName("us-ascii")
+        InputStream in = new ByteArrayInputStream(StandardCharsets.US_ASCII
                 .encode(mail).array());
         builder.parse(in);
         builder.to(position);
@@ -126,7 +125,7 @@ class PartContentBuilderMultipartAlternativeTest {
     }
 
     private List<Header> headers(String mail, int position) throws Exception {
-        InputStream in = new ByteArrayInputStream(Charset.forName("us-ascii")
+        InputStream in = new ByteArrayInputStream(StandardCharsets.US_ASCII
                 .encode(mail).array());
         builder.parse(in);
         builder.to(position);
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilsMultipartMixedTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilsMultipartMixedTest.java
index c39e743..95ea0f8 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilsMultipartMixedTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilsMultipartMixedTest.java
@@ -21,7 +21,7 @@ package org.apache.james.mailbox.store.search;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
@@ -123,7 +123,7 @@ class SearchUtilsMultipartMixedTest {
         builder.header("Subject", "A Mixed Multipart Mail");
         builder.header("Date", "Thu, 14 Feb 2008 12:00:00 +0000 (GMT)");
         builder.header("Content-Type", "multipart/mixed;boundary=1729");
-        builder.body(Charset.forName("us-ascii").encode(BODY).array());
+        builder.body(StandardCharsets.US_ASCII.encode(BODY).array());
         row = builder.build();
         recent = new ArrayList<>();
         
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilsRFC822Test.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilsRFC822Test.java
index 5c33cff..ab84077 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilsRFC822Test.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilsRFC822Test.java
@@ -21,7 +21,7 @@ package org.apache.james.mailbox.store.search;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
@@ -64,7 +64,7 @@ class SearchUtilsRFC822Test {
         builder.header("To", FROM_ADDRESS);
         builder.header("Subject", "A " + SUBJECT_PART + " Multipart Mail");
         builder.header("Date", "Thu, 14 Feb 2008 12:00:00 +0000 (GMT)");
-        builder.body(Charset.forName("us-ascii").encode(BODY).array());
+        builder.body(StandardCharsets.US_ASCII.encode(BODY).array());
         row = builder.build();
         
         Iterator<MailboxMessage> messages = null;
diff --git a/mpt/core/src/main/java/org/apache/james/mpt/helper/ByteBufferInputStream.java b/mpt/core/src/main/java/org/apache/james/mpt/helper/ByteBufferInputStream.java
index 9658888..a50ad93 100644
--- a/mpt/core/src/main/java/org/apache/james/mpt/helper/ByteBufferInputStream.java
+++ b/mpt/core/src/main/java/org/apache/james/mpt/helper/ByteBufferInputStream.java
@@ -23,14 +23,14 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
-import java.nio.charset.Charset;
 import java.nio.charset.CharsetEncoder;
+import java.nio.charset.StandardCharsets;
 
 
 public class ByteBufferInputStream extends InputStream {
     private final ByteBuffer buffer = ByteBuffer.allocate(160384);
 
-    private final CharsetEncoder encoder = Charset.forName("ASCII").newEncoder();
+    private final CharsetEncoder encoder = StandardCharsets.US_ASCII.newEncoder();
 
     private boolean readLast = true;
 
diff --git a/mpt/core/src/main/java/org/apache/james/mpt/helper/ByteBufferOutputStream.java b/mpt/core/src/main/java/org/apache/james/mpt/helper/ByteBufferOutputStream.java
index f080849..bb51dc9 100644
--- a/mpt/core/src/main/java/org/apache/james/mpt/helper/ByteBufferOutputStream.java
+++ b/mpt/core/src/main/java/org/apache/james/mpt/helper/ByteBufferOutputStream.java
@@ -19,18 +19,18 @@
 
 package org.apache.james.mpt.helper;
 
+import static java.nio.charset.StandardCharsets.US_ASCII;
+
 import java.io.IOException;
 import java.io.OutputStream;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
-import java.nio.charset.Charset;
 
 import org.apache.james.mpt.api.Continuation;
 
 public class ByteBufferOutputStream extends OutputStream {
 
     private final ByteBuffer buffer = ByteBuffer.allocate(160384);
-    private final Charset ascii = Charset.forName("ASCII");
     private final Continuation continuation;
     private boolean matchPlus = false;
     private boolean matchCR = false;
@@ -41,7 +41,7 @@ public class ByteBufferOutputStream extends OutputStream {
     }
 
     public void write(String message) throws IOException {
-        ascii.newEncoder().encode(CharBuffer.wrap(message), buffer, true);
+        US_ASCII.newEncoder().encode(CharBuffer.wrap(message), buffer, true);
     }
 
     @Override
@@ -85,7 +85,7 @@ public class ByteBufferOutputStream extends OutputStream {
             limit = 0;
         }
         readOnlyBuffer.limit(limit);
-        String result = ascii.decode(readOnlyBuffer).toString();
+        String result = US_ASCII.decode(readOnlyBuffer).toString();
         buffer.compact();
         return result;
     }
diff --git a/mpt/core/src/main/java/org/apache/james/mpt/helper/ScriptBuilder.java b/mpt/core/src/main/java/org/apache/james/mpt/helper/ScriptBuilder.java
index eb3199c..57a8d15 100644
--- a/mpt/core/src/main/java/org/apache/james/mpt/helper/ScriptBuilder.java
+++ b/mpt/core/src/main/java/org/apache/james/mpt/helper/ScriptBuilder.java
@@ -19,6 +19,8 @@
 
 package org.apache.james.mpt.helper;
 
+import static java.nio.charset.StandardCharsets.US_ASCII;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.InetSocketAddress;
@@ -27,7 +29,6 @@ import java.nio.CharBuffer;
 import java.nio.channels.ReadableByteChannel;
 import java.nio.channels.SocketChannel;
 import java.nio.channels.WritableByteChannel;
-import java.nio.charset.Charset;
 import java.util.Arrays;
 import java.util.Locale;
 
@@ -1098,8 +1099,6 @@ public class ScriptBuilder {
 
     public static final class Client {
 
-        private static final Charset ASCII = Charset.forName("us-ascii");
-
         private final Out out;
 
         private final ReadableByteChannel source;
@@ -1218,7 +1217,7 @@ public class ScriptBuilder {
 
         public void write(String phrase) throws Exception {
             out.print(phrase);
-            final ByteBuffer buffer = ASCII.encode(phrase);
+            final ByteBuffer buffer = US_ASCII.encode(phrase);
             writeRemaining(buffer);
         }
 
diff --git a/mpt/core/src/main/java/org/apache/james/mpt/session/ExternalSession.java b/mpt/core/src/main/java/org/apache/james/mpt/session/ExternalSession.java
index 17812a1..5eaf98e 100644
--- a/mpt/core/src/main/java/org/apache/james/mpt/session/ExternalSession.java
+++ b/mpt/core/src/main/java/org/apache/james/mpt/session/ExternalSession.java
@@ -19,10 +19,11 @@
 
 package org.apache.james.mpt.session;
 
+import static java.nio.charset.StandardCharsets.US_ASCII;
+
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.channels.SocketChannel;
-import java.nio.charset.Charset;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.lang3.NotImplementedException;
@@ -42,8 +43,6 @@ public final class ExternalSession implements Session {
 
     private final ByteBuffer readBuffer;
 
-    private final Charset ascii;
-
     private final ByteBuffer lineEndBuffer;
 
     private boolean first = true;
@@ -59,7 +58,6 @@ public final class ExternalSession implements Session {
         this.socket = socket;
         this.monitor = monitor;
         readBuffer = ByteBuffer.allocateDirect(2048);
-        ascii = Charset.forName("US-ASCII");
         lineEndBuffer = ByteBuffer.wrap(CRLF);
         this.shabang = shabang;
     }
@@ -161,7 +159,7 @@ public final class ExternalSession implements Session {
     public void writeLine(String line) throws Exception {
         monitor.note("-> " + line);
         monitor.debug("[Writing line]");
-        ByteBuffer writeBuffer = ascii.encode(line);
+        ByteBuffer writeBuffer = US_ASCII.encode(line);
         while (writeBuffer.hasRemaining()) {
             socket.write(writeBuffer);
         }
@@ -187,7 +185,7 @@ public final class ExternalSession implements Session {
         final String TAB = " ";
 
         return "External ( " + "socket = " + this.socket + TAB + "monitor = " + this.monitor + TAB
-                + "readBuffer = " + this.readBuffer + TAB + "ascii = " + this.ascii + TAB + "lineEndBuffer = "
+                + "readBuffer = " + this.readBuffer + TAB + "lineEndBuffer = "
                 + this.lineEndBuffer + TAB + "first = " + this.first + TAB + "shabang = " + this.shabang + TAB + " )";
     }
 
diff --git a/mpt/core/src/test/java/org/apache/james/mpt/DiscardProtocol.java b/mpt/core/src/test/java/org/apache/james/mpt/DiscardProtocol.java
index 2774079..36259e0 100644
--- a/mpt/core/src/test/java/org/apache/james/mpt/DiscardProtocol.java
+++ b/mpt/core/src/test/java/org/apache/james/mpt/DiscardProtocol.java
@@ -19,13 +19,14 @@
 
 package org.apache.james.mpt;
 
+import static java.nio.charset.StandardCharsets.US_ASCII;
+
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
 import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.SocketChannel;
-import java.nio.charset.Charset;
 import java.util.Collection;
 import java.util.LinkedList;
 import java.util.Queue;
@@ -38,9 +39,6 @@ import org.slf4j.LoggerFactory;
  * Simple <a href='http://tools.ietf.org/html/rfc863'>RFC 863</a> implementation.
  */
 public class DiscardProtocol {
-
-    private static final Charset ASCII = Charset.forName("US-ASCII");
-    
     private static final int SOCKET_CONNECTION_WAIT_MILLIS = 30;
     
     private static final int IDLE_TIMEOUT = 120000;
@@ -259,7 +257,7 @@ public class DiscardProtocol {
          */
         private void decant() {
             buffer.flip();
-            final CharBuffer decoded = ASCII.decode(buffer);
+            final CharBuffer decoded = US_ASCII.decode(buffer);
             out.append(decoded);
             buffer.clear();
         }
diff --git a/protocols/api/src/main/java/org/apache/james/protocols/api/ProtocolSessionImpl.java b/protocols/api/src/main/java/org/apache/james/protocols/api/ProtocolSessionImpl.java
index ec27d9e..f824826 100644
--- a/protocols/api/src/main/java/org/apache/james/protocols/api/ProtocolSessionImpl.java
+++ b/protocols/api/src/main/java/org/apache/james/protocols/api/ProtocolSessionImpl.java
@@ -19,6 +19,8 @@
 
 package org.apache.james.protocols.api;
 
+import static java.nio.charset.StandardCharsets.US_ASCII;
+
 import java.net.InetSocketAddress;
 import java.nio.charset.Charset;
 import java.util.HashMap;
@@ -41,7 +43,6 @@ public class ProtocolSessionImpl implements ProtocolSession {
     private final Map<AttachmentKey<?>, Object> sessionState;
     private Username username;
     protected final ProtocolConfiguration config;
-    private static final Charset CHARSET = Charset.forName("US-ASCII");
     private static final String DELIMITER = "\r\n";
     
     public ProtocolSessionImpl(ProtocolTransport transport, ProtocolConfiguration config) {
@@ -173,7 +174,7 @@ public class ProtocolSessionImpl implements ProtocolSession {
      */
     @Override
     public Charset getCharset() {
-        return CHARSET;
+        return US_ASCII;
     }
 
     /**
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java
index 458f3e2..e8706be 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java
@@ -19,6 +19,8 @@
 
 package org.apache.james.imap.decode;
 
+import static java.nio.charset.StandardCharsets.US_ASCII;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteBuffer;
@@ -55,8 +57,6 @@ public abstract class ImapRequestLineReader {
 
     private static final int QUOTED_BUFFER_INITIAL_CAPACITY = 64;
 
-    private static final Charset US_ASCII = Charset.forName("US-ASCII");
-
     protected boolean nextSeen = false;
 
     protected char nextChar; // unknown
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/encode/base/ImapResponseComposerImpl.java b/protocols/imap/src/main/java/org/apache/james/imap/encode/base/ImapResponseComposerImpl.java
index 55908bb..bbe4698 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/encode/base/ImapResponseComposerImpl.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/encode/base/ImapResponseComposerImpl.java
@@ -19,8 +19,9 @@
 
 package org.apache.james.imap.encode.base;
 
+import static java.nio.charset.StandardCharsets.US_ASCII;
+
 import java.io.IOException;
-import java.nio.charset.Charset;
 
 import javax.mail.Flags;
 
@@ -52,13 +53,10 @@ public class ImapResponseComposerImpl implements ImapConstants, ImapResponseComp
 
     private final FastByteArrayOutputStream buffer;
 
-    private final Charset usAscii;
-
     private boolean skipNextSpace;
 
     public ImapResponseComposerImpl(ImapResponseWriter writer, int bufferSize) {
         skipNextSpace = false;
-        usAscii = Charset.forName("US-ASCII");
         this.writer = writer;
         this.buffer = new FastByteArrayOutputStream(bufferSize);
     }
@@ -197,7 +195,7 @@ public class ImapResponseComposerImpl implements ImapConstants, ImapResponseComp
 
 
     private void writeASCII(String string) throws IOException {
-        buffer.write(string.getBytes(usAscii));
+        buffer.write(string.getBytes(US_ASCII));
     }
 
     @Override
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/AuthenticateProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/AuthenticateProcessor.java
index 24620b9..38709cf 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/AuthenticateProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/AuthenticateProcessor.java
@@ -20,7 +20,7 @@
 package org.apache.james.imap.processor;
 
 import java.io.Closeable;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Base64;
 import java.util.List;
@@ -71,7 +71,7 @@ public class AuthenticateProcessor extends AbstractAuthProcessor<AuthenticateReq
                     responder.respond(new AuthenticateResponse());
                     session.pushLineHandler((requestSession, data) -> {
                         // cut of the CRLF
-                        String initialClientResponse = new String(data, 0, data.length - 2, Charset.forName("US-ASCII"));
+                        String initialClientResponse = new String(data, 0, data.length - 2, StandardCharsets.US_ASCII);
 
                         doPlainAuth(initialClientResponse, requestSession, request, responder);
 
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java b/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java
index dad9fef..8296512 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java
@@ -19,6 +19,8 @@
 
 package org.apache.james.imap.decode.parser;
 
+import static java.nio.charset.StandardCharsets.US_ASCII;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.apache.james.imap.ImapFixture.TAG;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.ArgumentMatchers.eq;
@@ -30,8 +32,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
 
 import org.apache.james.imap.api.ImapConstants;
 import org.apache.james.imap.api.ImapMessage;
@@ -46,24 +46,19 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class SearchCommandParserCharsetTest {
-
-    private static final Charset UTF8 = Charset.forName("UTF-8");
-
-    private static final Charset ASCII = Charset.forName("US-ASCII");
-
     private static final String ASCII_SEARCH_TERM = "A Search Term";
 
     private static final String NON_ASCII_SEARCH_TERM = "как Дела?";
 
     private static final byte[] BYTES_NON_ASCII_SEARCH_TERM = NioUtils.toBytes(
-            NON_ASCII_SEARCH_TERM, UTF8);
+            NON_ASCII_SEARCH_TERM, UTF_8);
 
     private static final byte[] BYTES_UTF8_NON_ASCII_SEARCH_TERM = NioUtils
-            .add(NioUtils.toBytes(" {16}\r\n", ASCII),
+            .add(NioUtils.toBytes(" {16}\r\n", US_ASCII),
                     BYTES_NON_ASCII_SEARCH_TERM);
 
     private static final byte[] CHARSET = NioUtils.toBytes("CHARSET UTF-8 ",
-            ASCII);
+        US_ASCII);
 
     SearchCommandParser parser;
     StatusResponseFactory mockStatusResponseFactory;
@@ -79,7 +74,7 @@ public class SearchCommandParserCharsetTest {
     @Test
     public void testBadCharset() throws Exception {
         ImapRequestLineReader reader = new ImapRequestStreamLineReader(
-                new ByteArrayInputStream("CHARSET BOGUS ".getBytes(StandardCharsets.US_ASCII)),
+                new ByteArrayInputStream("CHARSET BOGUS ".getBytes(US_ASCII)),
                 new ByteArrayOutputStream());
         parser.decode(reader, TAG, false, new FakeImapSession());
 
@@ -95,50 +90,50 @@ public class SearchCommandParserCharsetTest {
     @Test
     public void testBCCShouldConvertCharset() throws Exception {
         SearchKey key = SearchKey.buildBcc(NON_ASCII_SEARCH_TERM);
-        checkUTF8Valid("BCC".getBytes(StandardCharsets.US_ASCII), key);
+        checkUTF8Valid("BCC".getBytes(US_ASCII), key);
     }
 
     @Test
     public void testBODYShouldConvertCharset() throws Exception {
         SearchKey key = SearchKey.buildBody(NON_ASCII_SEARCH_TERM);
-        checkUTF8Valid("BODY".getBytes(StandardCharsets.US_ASCII), key);
+        checkUTF8Valid("BODY".getBytes(US_ASCII), key);
     }
 
     @Test
     public void testCCShouldConvertCharset() throws Exception {
         SearchKey key = SearchKey.buildCc(NON_ASCII_SEARCH_TERM);
-        checkUTF8Valid("CC".getBytes(StandardCharsets.US_ASCII), key);
+        checkUTF8Valid("CC".getBytes(US_ASCII), key);
     }
 
     @Test
     public void testFROMShouldConvertCharset() throws Exception {
         SearchKey key = SearchKey.buildFrom(NON_ASCII_SEARCH_TERM);
-        checkUTF8Valid("FROM".getBytes(StandardCharsets.US_ASCII), key);
+        checkUTF8Valid("FROM".getBytes(US_ASCII), key);
     }
 
     @Test
     public void testHEADERShouldConvertCharset() throws Exception {
         SearchKey key = SearchKey
                 .buildHeader("whatever", NON_ASCII_SEARCH_TERM);
-        checkUTF8Valid("HEADER whatever".getBytes(StandardCharsets.US_ASCII), key);
+        checkUTF8Valid("HEADER whatever".getBytes(US_ASCII), key);
     }
 
     @Test
     public void testSUBJECTShouldConvertCharset() throws Exception {
         SearchKey key = SearchKey.buildSubject(NON_ASCII_SEARCH_TERM);
-        checkUTF8Valid("SUBJECT".getBytes(StandardCharsets.US_ASCII), key);
+        checkUTF8Valid("SUBJECT".getBytes(US_ASCII), key);
     }
 
     @Test
     public void testTEXTShouldConvertCharset() throws Exception {
         SearchKey key = SearchKey.buildText(NON_ASCII_SEARCH_TERM);
-        checkUTF8Valid("TEXT".getBytes(StandardCharsets.US_ASCII), key);
+        checkUTF8Valid("TEXT".getBytes(US_ASCII), key);
     }
 
     @Test
     public void testTOShouldConvertCharset() throws Exception {
         SearchKey key = SearchKey.buildTo(NON_ASCII_SEARCH_TERM);
-        checkUTF8Valid("TO".getBytes(StandardCharsets.US_ASCII), key);
+        checkUTF8Valid("TO".getBytes(US_ASCII), key);
     }
 
     @Test
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraNodeConfTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraNodeConfTest.java
index 738e50b..361de3f 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraNodeConfTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraNodeConfTest.java
@@ -24,7 +24,7 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.nio.ByteBuffer;
 import java.nio.channels.SocketChannel;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.james.backends.cassandra.DockerCassandra;
 import org.apache.james.backends.cassandra.init.configuration.ClusterConfiguration;
@@ -128,6 +128,6 @@ class CassandraNodeConfTest {
         ByteBuffer byteBuffer = ByteBuffer.allocate(1000);
         socketChannel.read(byteBuffer);
         byte[] bytes = byteBuffer.array();
-        return new String(bytes, Charset.forName("UTF-8"));
+        return new String(bytes, StandardCharsets.UTF_8);
     }
 }
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
index 8afe525..f6c8531 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
@@ -25,7 +25,7 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.nio.ByteBuffer;
 import java.nio.channels.SocketChannel;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
@@ -114,6 +114,6 @@ class JamesServerWithRetryConnectionTest {
         ByteBuffer byteBuffer = ByteBuffer.allocate(1000);
         socketChannel.read(byteBuffer);
         byte[] bytes = byteBuffer.array();
-        return new String(bytes, Charset.forName("UTF-8"));
+        return new String(bytes, StandardCharsets.UTF_8);
     }
 }
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/CassandraSchemaVersionStartUpCheckTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/CassandraSchemaVersionStartUpCheckTest.java
index d1402e9..e22bb48 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/CassandraSchemaVersionStartUpCheckTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/CassandraSchemaVersionStartUpCheckTest.java
@@ -27,7 +27,7 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.nio.ByteBuffer;
 import java.nio.channels.SocketChannel;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.Optional;
 
 import org.apache.james.CassandraExtension;
@@ -148,6 +148,6 @@ class CassandraSchemaVersionStartUpCheckTest {
         socketChannel.read(byteBuffer);
         byte[] bytes = byteBuffer.array();
 
-        return new String(bytes, Charset.forName("UTF-8"));
+        return new String(bytes, StandardCharsets.UTF_8);
     }
 }
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerContract.java b/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerContract.java
index 0f241d8..7c71bc4 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerContract.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerContract.java
@@ -24,7 +24,7 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.nio.ByteBuffer;
 import java.nio.channels.SocketChannel;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.james.modules.protocols.ImapGuiceProbe;
 import org.apache.james.modules.protocols.LmtpGuiceProbe;
@@ -79,6 +79,6 @@ public interface JamesServerContract {
         ByteBuffer byteBuffer = ByteBuffer.allocate(1000);
         socketChannel.read(byteBuffer);
         byte[] bytes = byteBuffer.array();
-        return new String(bytes, Charset.forName("UTF-8"));
+        return new String(bytes, StandardCharsets.UTF_8);
     }
 }
diff --git a/server/container/guice/jpa-smtp-mariadb/src/test/java/org/apache/james/JPAJamesServerTest.java b/server/container/guice/jpa-smtp-mariadb/src/test/java/org/apache/james/JPAJamesServerTest.java
index 998b6ef..6f141fb 100644
--- a/server/container/guice/jpa-smtp-mariadb/src/test/java/org/apache/james/JPAJamesServerTest.java
+++ b/server/container/guice/jpa-smtp-mariadb/src/test/java/org/apache/james/JPAJamesServerTest.java
@@ -25,7 +25,7 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.nio.ByteBuffer;
 import java.nio.channels.SocketChannel;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.james.modules.protocols.SmtpGuiceProbe;
 import org.apache.james.server.core.configuration.Configuration;
@@ -84,7 +84,7 @@ public class JPAJamesServerTest {
         ByteBuffer byteBuffer = ByteBuffer.allocate(1000);
         socketChannel.read(byteBuffer);
         byte[] bytes = byteBuffer.array();
-        return new String(bytes, Charset.forName("UTF-8"));
+        return new String(bytes, StandardCharsets.UTF_8);
     }
 
 }
diff --git a/server/container/guice/jpa-smtp/src/test/java/org/apache/james/JPAJamesServerTest.java b/server/container/guice/jpa-smtp/src/test/java/org/apache/james/JPAJamesServerTest.java
index 72cc48a..542022a 100644
--- a/server/container/guice/jpa-smtp/src/test/java/org/apache/james/JPAJamesServerTest.java
+++ b/server/container/guice/jpa-smtp/src/test/java/org/apache/james/JPAJamesServerTest.java
@@ -25,7 +25,7 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.nio.ByteBuffer;
 import java.nio.channels.SocketChannel;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import javax.persistence.EntityManagerFactory;
 
@@ -91,7 +91,7 @@ public class JPAJamesServerTest {
         ByteBuffer byteBuffer = ByteBuffer.allocate(1000);
         socketChannel.read(byteBuffer);
         byte[] bytes = byteBuffer.array();
-        return new String(bytes, Charset.forName("UTF-8"));
+        return new String(bytes, StandardCharsets.UTF_8);
     }
 
 }


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


[james-project] 08/15: [REFACTORING] Use default methods in Mapper interface

Posted by rc...@apache.org.
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 81b8cc9114a440bc5ade47669f8ca69e5a63b48c
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sun Dec 6 21:35:47 2020 +0700

    [REFACTORING] Use default methods in Mapper interface
    
    Add a reactive transaction handling in the API
---
 .../mailbox/cassandra/mail/CassandraAnnotationMapper.java |  4 ----
 .../mailbox/cassandra/mail/CassandraAttachmentMapper.java |  9 ---------
 .../mailbox/cassandra/mail/CassandraMailboxMapper.java    | 11 -----------
 .../mailbox/cassandra/mail/CassandraMessageMapper.java    | 10 ----------
 .../cassandra/user/CassandraSubscriptionMapper.java       |  6 ------
 .../mailbox/jpa/mail/TransactionalAnnotationMapper.java   | 11 -----------
 .../mailbox/jpa/mail/TransactionalMailboxMapper.java      | 11 -----------
 .../mailbox/jpa/mail/TransactionalMessageMapper.java      | 11 -----------
 .../james/mailbox/maildir/mail/MaildirMailboxMapper.java  |  5 -----
 .../james/mailbox/maildir/mail/MaildirMessageMapper.java  |  6 ------
 .../mailbox/maildir/user/MaildirSubscriptionMapper.java   |  6 ------
 .../mailbox/inmemory/mail/InMemoryAnnotationMapper.java   | 11 -----------
 .../mailbox/inmemory/mail/InMemoryAttachmentMapper.java   | 10 ----------
 .../mailbox/inmemory/mail/InMemoryMailboxMapper.java      | 11 -----------
 .../mailbox/inmemory/mail/InMemoryMessageMapper.java      |  5 -----
 .../mailbox/inmemory/mail/InMemoryModSeqProvider.java     |  1 -
 .../mailbox/inmemory/user/InMemorySubscriptionMapper.java |  6 ------
 .../apache/james/mailbox/store/transaction/Mapper.java    | 14 ++++++++++++--
 .../mailbox/store/transaction/NonTransactionalMapper.java |  7 -------
 .../mailbox/store/transaction/TransactionalMapper.java    |  2 +-
 .../store/StoreMailboxMessageResultIteratorTest.java      | 15 +--------------
 21 files changed, 14 insertions(+), 158 deletions(-)

diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapper.java
index 7a96dd7..c9c0ee7 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapper.java
@@ -170,8 +170,4 @@ public class CassandraAnnotationMapper extends NonTransactionalMapper implements
             .map(this::toAnnotation)
             .filter(annotation -> key.isParentOrIsEqual(annotation.getKey()));
     }
-
-    @Override
-    public void endRequest() {
-    }
 }
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java
index bc2cb99..ce98ec0 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java
@@ -69,15 +69,6 @@ public class CassandraAttachmentMapper implements AttachmentMapper {
     }
 
     @Override
-    public void endRequest() {
-    }
-
-    @Override
-    public <T> T execute(Transaction<T> transaction) throws MailboxException {
-        return transaction.run();
-    }
-
-    @Override
     public AttachmentMetadata getAttachment(AttachmentId attachmentId) throws AttachmentNotFoundException {
         Preconditions.checkArgument(attachmentId != null);
         return getAttachmentInternal(attachmentId)
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
index 6032ef1..f4dbd1d 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
@@ -32,7 +32,6 @@ import org.apache.james.core.Username;
 import org.apache.james.mailbox.acl.ACLDiff;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
 import org.apache.james.mailbox.cassandra.mail.task.SolveMailboxInconsistenciesService;
-import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxExistsException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.model.Mailbox;
@@ -329,11 +328,6 @@ public class CassandraMailboxMapper implements MailboxMapper {
     }
 
     @Override
-    public <T> T execute(Transaction<T> transaction) throws MailboxException {
-        return transaction.run();
-    }
-
-    @Override
     public Mono<ACLDiff> updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) {
         CassandraId cassandraId = (CassandraId) mailbox.getMailboxId();
         return cassandraACLMapper.updateACL(cassandraId, mailboxACLCommand);
@@ -345,11 +339,6 @@ public class CassandraMailboxMapper implements MailboxMapper {
         return cassandraACLMapper.setACL(cassandraId, mailboxACL);
     }
 
-    @Override
-    public void endRequest() {
-        // Do nothing
-    }
-
     private Mono<Mailbox> toMailboxWithAcl(Mailbox mailbox) {
         CassandraId cassandraId = (CassandraId) mailbox.getMailboxId();
         return retrieveAcl(cassandraId)
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
index 1c9c587..ffc0f36 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
@@ -294,11 +294,6 @@ public class CassandraMessageMapper implements MessageMapper {
     }
 
     @Override
-    public void endRequest() {
-        // Do nothing
-    }
-
-    @Override
     public ModSeq getHighestModSeq(Mailbox mailbox) throws MailboxException {
         return modSeqProvider.highestModSeq(mailbox);
     }
@@ -417,11 +412,6 @@ public class CassandraMessageMapper implements MessageMapper {
     }
 
     @Override
-    public <T> T execute(Transaction<T> transaction) throws MailboxException {
-        return transaction.run();
-    }
-
-    @Override
     public MessageMetaData copy(Mailbox mailbox, MailboxMessage original) throws MailboxException {
         original.setFlags(new FlagsBuilder().add(original.createFlags()).add(Flag.RECENT).build());
         return setInMailbox(mailbox, original);
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/user/CassandraSubscriptionMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/user/CassandraSubscriptionMapper.java
index df22d6c..800f000 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/user/CassandraSubscriptionMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/user/CassandraSubscriptionMapper.java
@@ -80,10 +80,4 @@ public class CassandraSubscriptionMapper extends NonTransactionalMapper implemen
             .map((row) -> new Subscription(Username.of(row.getString(USER)), row.getString(MAILBOX)))
             .collect(Collectors.toList());
     }
-
-    @Override
-    public void endRequest() {
-        // nothing to do
-    }
-
 }
diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalAnnotationMapper.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalAnnotationMapper.java
index 4cb9930..7a0ff31 100644
--- a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalAnnotationMapper.java
+++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalAnnotationMapper.java
@@ -22,7 +22,6 @@ package org.apache.james.mailbox.jpa.mail;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.commons.lang3.NotImplementedException;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxAnnotation;
 import org.apache.james.mailbox.model.MailboxAnnotationKey;
@@ -38,16 +37,6 @@ public class TransactionalAnnotationMapper implements AnnotationMapper {
     }
 
     @Override
-    public void endRequest() {
-        throw new NotImplementedException("not implemented");
-    }
-
-    @Override
-    public <T> T execute(Transaction<T> transaction) {
-        throw new NotImplementedException("not implemented");
-    }
-
-    @Override
     public List<MailboxAnnotation> getAllAnnotations(MailboxId mailboxId) {
         return wrapped.getAllAnnotations(mailboxId);
     }
diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
index 5b6f9b8..d3ebc16 100644
--- a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
+++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
@@ -19,7 +19,6 @@
 
 package org.apache.james.mailbox.jpa.mail;
 
-import org.apache.commons.lang3.NotImplementedException;
 import org.apache.james.core.Username;
 import org.apache.james.mailbox.acl.ACLDiff;
 import org.apache.james.mailbox.model.Mailbox;
@@ -42,16 +41,6 @@ public class TransactionalMailboxMapper implements MailboxMapper {
     }
 
     @Override
-    public void endRequest() {
-        throw new NotImplementedException("not implemented");
-    }
-
-    @Override
-    public <T> T execute(Transaction<T> transaction) {
-        throw new NotImplementedException("not implemented");
-    }
-
-    @Override
     public Mono<Mailbox> create(MailboxPath mailboxPath, UidValidity uidValidity) {
         return wrapped.executeReactive(wrapped.create(mailboxPath, uidValidity));
     }
diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMessageMapper.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMessageMapper.java
index 1e7d09b..ad7e9e5 100644
--- a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMessageMapper.java
+++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMessageMapper.java
@@ -26,7 +26,6 @@ import java.util.Optional;
 
 import javax.mail.Flags;
 
-import org.apache.commons.lang3.NotImplementedException;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.ModSeq;
 import org.apache.james.mailbox.exception.MailboxException;
@@ -48,11 +47,6 @@ public class TransactionalMessageMapper implements MessageMapper {
     public TransactionalMessageMapper(JPAMessageMapper messageMapper) {
         this.messageMapper = messageMapper;
     }
-    
-    @Override
-    public void endRequest() {
-        throw new NotImplementedException("not implemented");
-    }
 
     @Override
     public MailboxCounters getMailboxCounters(Mailbox mailbox) throws MailboxException {
@@ -69,11 +63,6 @@ public class TransactionalMessageMapper implements MessageMapper {
     }
 
     @Override
-    public <T> T execute(Transaction<T> transaction) throws MailboxException {
-        throw new NotImplementedException("not implemented");
-    }
-
-    @Override
     public Iterator<MailboxMessage> findInMailbox(Mailbox mailbox, MessageRange set, FetchType type, int limit)
             throws MailboxException {
         return messageMapper.findInMailbox(mailbox, set, type, limit);
diff --git a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
index 9e02cf0..edadc5c 100644
--- a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
+++ b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
@@ -280,11 +280,6 @@ public class MaildirMailboxMapper extends NonTransactionalMapper implements Mail
                .flatMapIterable(mailboxes -> mailboxes.collect(Guavate.toImmutableList()));
     }
 
-    @Override
-    public void endRequest() {
-
-    }
-
     private List<Mailbox> visitUsersForMailboxList(File domain, File[] users) throws MailboxException {
         ImmutableList.Builder<Mailbox> mailboxList = ImmutableList.builder();
 
diff --git a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java
index 30ca42f..e670055 100644
--- a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java
+++ b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java
@@ -341,12 +341,6 @@ public class MaildirMessageMapper extends AbstractMessageMapper {
             .computeApplicableFlags();
     }
 
-    @Override
-    public void endRequest() {
-        // not used
-
-    }
-
     private List<MailboxMessage> findMessageInMailboxWithUID(Mailbox mailbox, MessageUid from)
             throws MailboxException {
         MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
diff --git a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/user/MaildirSubscriptionMapper.java b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/user/MaildirSubscriptionMapper.java
index c36096a..e278eef 100644
--- a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/user/MaildirSubscriptionMapper.java
+++ b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/user/MaildirSubscriptionMapper.java
@@ -91,12 +91,6 @@ public class MaildirSubscriptionMapper extends NonTransactionalMapper implements
             }
         }
     }
-
-    @Override
-    public void endRequest() {
-        // nothing to do
-    }
-    
     
     /**
      * Read the subscriptions for a particular user
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAnnotationMapper.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAnnotationMapper.java
index c4001c8..49ffa77 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAnnotationMapper.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAnnotationMapper.java
@@ -26,7 +26,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
 import java.util.function.Predicate;
 
 import org.apache.commons.lang3.StringUtils;
-import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.model.MailboxAnnotation;
 import org.apache.james.mailbox.model.MailboxAnnotationKey;
@@ -46,16 +45,6 @@ public class InMemoryAnnotationMapper implements AnnotationMapper {
         mailboxesAnnotations = HashBasedTable.create();
     }
 
-    @Override
-    public void endRequest() {
-
-    }
-
-    @Override
-    public <T> T execute(Transaction<T> transaction) throws MailboxException {
-        return transaction.run();
-    }
-
     private List<MailboxAnnotation> retrieveAllAnnotations(InMemoryId mailboxId) {
         lock.readLock().lock();
         try {
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAttachmentMapper.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAttachmentMapper.java
index c5237b9..80e0e83 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAttachmentMapper.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAttachmentMapper.java
@@ -111,16 +111,6 @@ public class InMemoryAttachmentMapper implements AttachmentMapper {
     }
 
     @Override
-    public void endRequest() {
-        // Do nothing
-    }
-
-    @Override
-    public <T> T execute(Transaction<T> transaction) throws MailboxException {
-        return transaction.run();
-    }
-
-    @Override
     public List<MessageAttachmentMetadata> storeAttachmentsForMessage(Collection<ParsedAttachment> parsedAttachments, MessageId ownerMessageId) throws MailboxException {
         return parsedAttachments.stream()
             .map(Throwing.<ParsedAttachment, MessageAttachmentMetadata>function(
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
index 0f76a8f..6bc7180 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
@@ -25,7 +25,6 @@ import java.util.function.Function;
 
 import org.apache.james.core.Username;
 import org.apache.james.mailbox.acl.ACLDiff;
-import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxExistsException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.inmemory.InMemoryId;
@@ -114,11 +113,6 @@ public class InMemoryMailboxMapper implements MailboxMapper {
     }
 
     @Override
-    public void endRequest() {
-        // Do nothing
-    }
-
-    @Override
     public Mono<Boolean> hasChildren(Mailbox mailbox, char delimiter) {
         String mailboxName = mailbox.getName() + delimiter;
         return Mono.fromCallable(mailboxesByPath::values)
@@ -139,11 +133,6 @@ public class InMemoryMailboxMapper implements MailboxMapper {
     }
 
     @Override
-    public <T> T execute(Transaction<T> transaction) throws MailboxException {
-        return transaction.run();
-    }
-
-    @Override
     public Mono<ACLDiff> updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) {
         return Mono.fromCallable(() -> {
             MailboxACL oldACL = mailbox.getACL();
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapper.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapper.java
index df9b8b2..56760f2 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapper.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapper.java
@@ -181,11 +181,6 @@ public class InMemoryMessageMapper extends AbstractMessageMapper {
     }
 
     @Override
-    public void endRequest() {
-        // Do nothing
-    }
-
-    @Override
     protected MessageMetaData copy(Mailbox mailbox, MessageUid uid, ModSeq modSeq, MailboxMessage original)
             throws MailboxException {
         SimpleMailboxMessage message = SimpleMailboxMessage.copy(mailbox.getMailboxId(), original);
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryModSeqProvider.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryModSeqProvider.java
index d4c80a1..390070a 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryModSeqProvider.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryModSeqProvider.java
@@ -35,7 +35,6 @@ public class InMemoryModSeqProvider implements ModSeqProvider {
     @Override
     public ModSeq nextModSeq(Mailbox mailbox) {
         return ModSeq.of(nextModSeq((InMemoryId) mailbox.getMailboxId()));
-
     }
 
     @Override
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/user/InMemorySubscriptionMapper.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/user/InMemorySubscriptionMapper.java
index 663fe71..04691a9 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/user/InMemorySubscriptionMapper.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/user/InMemorySubscriptionMapper.java
@@ -71,10 +71,4 @@ public class InMemorySubscriptionMapper extends NonTransactionalMapper implement
             subscriptionsByUser.clear();
         }
     }
-
-    @Override
-    public void endRequest() {
-        // nothing to do
-    }
-
 }
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/Mapper.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/Mapper.java
index 1560e83..d817a1c 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/Mapper.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/Mapper.java
@@ -21,6 +21,8 @@ package org.apache.james.mailbox.store.transaction;
 
 import org.apache.james.mailbox.exception.MailboxException;
 
+import reactor.core.publisher.Mono;
+
 /**
  * Mapper which execute units of work in a {@link Transaction}
  */
@@ -29,12 +31,20 @@ public interface Mapper {
     /**
      * IMAP Request was complete. Cleanup all Request scoped stuff
      */
-    void endRequest();
+    default void endRequest() {
+
+    }
     
     /**
      * Execute the given Transaction
      */
-    <T> T execute(Transaction<T> transaction) throws MailboxException;
+    default <T> T execute(Transaction<T> transaction) throws MailboxException {
+        return transaction.run();
+    }
+
+    default <T> Mono<T> executeReactive(Mono<T> transaction) {
+        return transaction;
+    }
 
     /**
      * Unit of work executed in a Transaction
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/NonTransactionalMapper.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/NonTransactionalMapper.java
index 7417ce5..8fd8ecf 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/NonTransactionalMapper.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/NonTransactionalMapper.java
@@ -18,8 +18,6 @@
  ****************************************************************/
 package org.apache.james.mailbox.store.transaction;
 
-import org.apache.james.mailbox.exception.MailboxException;
-
 /**
  * A Mapper which does no transaction handling. It just executes the execute() method
  * of the Transaction object without any special handling.
@@ -28,9 +26,4 @@ import org.apache.james.mailbox.exception.MailboxException;
  */
 public abstract class NonTransactionalMapper implements Mapper {
 
-    @Override
-    public final <T> T execute(Transaction<T> transaction) throws MailboxException {
-        return transaction.run();
-    }
-
 }
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/TransactionalMapper.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/TransactionalMapper.java
index 139d8e7..4bc1073 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/TransactionalMapper.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/transaction/TransactionalMapper.java
@@ -47,7 +47,7 @@ public abstract class TransactionalMapper implements Mapper {
     public final <T> Mono<T> executeReactive(Mono<T> transaction) {
         return Mono.fromRunnable(Throwing.runnable(this::begin).sneakyThrow())
             .then(transaction)
-            .doOnNext(Throwing.consumer(ignored -> commit()).sneakyThrow())
+            .doOnSuccess(Throwing.<T>consumer(ignored -> commit()).sneakyThrow())
             .doOnError(MailboxException.class, Throwing.consumer(e -> rollback()).sneakyThrow());
     }
 
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxMessageResultIteratorTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxMessageResultIteratorTest.java
index d608338..fc50181 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxMessageResultIteratorTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxMessageResultIteratorTest.java
@@ -68,25 +68,12 @@ class StoreMailboxMessageResultIteratorTest {
         }
 
         @Override
-        public void endRequest() {
-            throw new UnsupportedOperationException();
-        }
-
-        @Override
-        public <T> T execute(Transaction<T> transaction) {
-            throw new UnsupportedOperationException();
-        }
-
-        @Override
         public MailboxCounters getMailboxCounters(Mailbox mailbox) {
             throw new UnsupportedOperationException();
         }
 
         @Override
-        public Iterator<MailboxMessage> findInMailbox(Mailbox mailbox, MessageRange set,
-                                                              org.apache.james.mailbox.store.mail.MessageMapper.FetchType type, int limit)
-                throws MailboxException {
-            
+        public Iterator<MailboxMessage> findInMailbox(Mailbox mailbox, MessageRange set, FetchType type, int limit) {
             List<MailboxMessage> messages = new ArrayList<>();
             for (MessageUid uid: Iterables.limit(set, limit)) {
                 if (messageRange.includes(uid)) {


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


[james-project] 03/15: JAMES-2578 No longer rely on Java serialization for JMS and ActiveMQ

Posted by rc...@apache.org.
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 f43a55845b83d10deba626dd1903130bc14383ac
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Dec 7 13:39:31 2020 +0700

    JAMES-2578 No longer rely on Java serialization for JMS and ActiveMQ
---
 .../apache/james/queue/activemq/ActiveMQMailQueueBlobTest.java   | 6 ------
 .../org/apache/james/queue/activemq/ActiveMQMailQueueTest.java   | 6 ------
 .../java/org/apache/james/queue/jms/JMSCacheableMailQueue.java   | 9 ++++++---
 .../org/apache/james/queue/jms/JMSCacheableMailQueueTest.java    | 6 ------
 4 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueBlobTest.java b/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueBlobTest.java
index 71a970e..1a68b89 100644
--- a/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueBlobTest.java
+++ b/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueBlobTest.java
@@ -98,12 +98,6 @@ public class ActiveMQMailQueueBlobTest implements DelayedManageableMailQueueCont
         return mailQueue;
     }
 
-    @Override
-    @Disabled("JAMES-3431 No support for Attribute collection Java serialization yet")
-    public void queueShouldPreserveDsnParameters() {
-
-    }
-
     @Test
     @Override
     @Disabled("JAMES-2295 Disabled as test was dead-locking")
diff --git a/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueTest.java b/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueTest.java
index 8884645..b90c1a1 100644
--- a/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueTest.java
+++ b/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueTest.java
@@ -77,12 +77,6 @@ public class ActiveMQMailQueueTest implements DelayedManageableMailQueueContract
         return mailQueue;
     }
 
-    @Override
-    @Disabled("JAMES-3431 No support for Attribute collection Java serialization yet")
-    public void queueShouldPreserveDsnParameters() {
-
-    }
-
     @Test
     @Override
     @Disabled("JAMES-2295 Disabled as test was dead-locking")
diff --git a/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java b/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java
index 1084b17..e6950c7 100644
--- a/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java
+++ b/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java
@@ -20,7 +20,6 @@ package org.apache.james.queue.jms;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.Serializable;
 import java.time.DateTimeException;
 import java.time.Duration;
 import java.time.Instant;
@@ -359,7 +358,7 @@ public class JMSCacheableMailQueue implements ManageableMailQueue, JMSSupport, M
         props.putAll(mail.attributes()
             .collect(Guavate.toImmutableMap(
                 attribute -> attribute.getName().asString(),
-                attribute -> SerializationUtil.serialize((Serializable) attribute.getValue().value()))));
+                attribute -> attribute.getValue().toJson().toString())));
 
         ImmutableList<String> attributeNames = mail.attributeNames()
             .map(AttributeName::asString)
@@ -453,7 +452,11 @@ public class JMSCacheableMailQueue implements ManageableMailQueue, JMSSupport, M
         Object attrValue = Throwing.function(message::getObjectProperty).apply(name);
 
         if (attrValue instanceof String) {
-            return Stream.of(new Attribute(AttributeName.of(name), AttributeValue.ofAny(SerializationUtil.deserialize((String) attrValue))));
+            try {
+                return Stream.of(new Attribute(AttributeName.of(name), AttributeValue.fromJsonString((String) attrValue)));
+            } catch (IOException e) {
+                LOGGER.error("Error deserializing mail attribute {} with value {}", name, attrValue, e);
+            }
         } else {
             LOGGER.error("Not supported mail attribute {} of type {} for mail {}", name, attrValue, name);
         }
diff --git a/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/JMSCacheableMailQueueTest.java b/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/JMSCacheableMailQueueTest.java
index 6d75f0d..fb0e189 100644
--- a/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/JMSCacheableMailQueueTest.java
+++ b/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/JMSCacheableMailQueueTest.java
@@ -75,12 +75,6 @@ public class JMSCacheableMailQueueTest implements DelayedManageableMailQueueCont
     }
 
     @Override
-    @Disabled("JAMES-3431 No support for Attribute collection Java serialization yet")
-    public void queueShouldPreserveDsnParameters() {
-
-    }
-
-    @Override
     @Disabled("JAMES-2295 Disabled as test was dead-locking")
     public void dequeueCanBeChainedBeforeAck() {
 


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


[james-project] 11/15: [REFACTORING] StoreMailboxManager: get rid of nested block call upon mailbox creation

Posted by rc...@apache.org.
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


[james-project] 05/15: JAMES-2578 Remove SerializationUtil

Posted by rc...@apache.org.
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 4c0f894bfcb705973c7b0a1a54055caaf3d95312
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Dec 7 14:25:13 2020 +0700

    JAMES-2578 Remove SerializationUtil
---
 .../org/apache/james/util/SerializationUtil.java   |  64 -------------
 .../apache/james/util/SerializationUtilTest.java   | 106 ---------------------
 2 files changed, 170 deletions(-)

diff --git a/server/container/util/src/main/java/org/apache/james/util/SerializationUtil.java b/server/container/util/src/main/java/org/apache/james/util/SerializationUtil.java
deleted file mode 100644
index 3987ad6..0000000
--- a/server/container/util/src/main/java/org/apache/james/util/SerializationUtil.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.util;
-
-import java.io.Serializable;
-import java.util.Base64;
-import java.util.Optional;
-
-import org.apache.commons.lang3.SerializationUtils;
-
-/**
- * This class is similar to {@link SerializationUtils}. Unlike {@link SerializationUtils} this class operates with
- * {@code String}s and not byte arrays.
- * <p>
- * The main advantage of this utility is that it introduces an additional operation after serialization and before
- * deserialization. The operation consists in encoding/decoding the serialized/deserialized data in Base64, so that data
- * can be safely transmitted over the wire.
- */
-public class SerializationUtil {
-    /**
-     * Serialize the input object using standard mechanisms then encodes result using base64 encoding.
-     *
-     * @param obj The object that needs to be serialized.
-     *
-     * @return The base64 representation of {@code obj}.
-     */
-    public static String serialize(Serializable obj) {
-        return Optional.ofNullable(obj)
-                .map(SerializationUtils::serialize)
-                .map(Base64.getEncoder()::encodeToString)
-                .orElse(null);
-    }
-
-    /**
-     * Decodes the input base64 string and deserialize it.
-     *
-     * @param <T>    The resulting type after deserialization.
-     * @param object The base64 encoded string.
-     *
-     * @return The deserialized object.
-     */
-    public static <T extends Serializable> T deserialize(String object) {
-        return Optional.ofNullable(object)
-                .map(Base64.getDecoder()::decode)
-                .<T>map(SerializationUtils::deserialize)
-                .orElse(null);
-    }
-}
diff --git a/server/container/util/src/test/java/org/apache/james/util/SerializationUtilTest.java b/server/container/util/src/test/java/org/apache/james/util/SerializationUtilTest.java
deleted file mode 100644
index c648880..0000000
--- a/server/container/util/src/test/java/org/apache/james/util/SerializationUtilTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.util;
-
-import static org.apache.james.util.SerializationUtil.deserialize;
-import static org.apache.james.util.SerializationUtil.serialize;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-
-import java.io.Serializable;
-import java.nio.charset.StandardCharsets;
-import java.util.Base64;
-import java.util.Objects;
-import java.util.Optional;
-
-import org.apache.commons.lang3.SerializationException;
-import org.junit.jupiter.api.Test;
-
-class SerializationUtilTest {
-    /**
-     * Serializes and deserializes the provided object.
-     *
-     * @param obj The object that needs to be serialized.
-     * @param <T> The type of the provided object.
-     *
-     * @return The provided object.
-     */
-    private static <T extends Serializable> T roundtrip(T obj) {
-        return Optional.ofNullable(obj)
-                .map(SerializationUtil::serialize)
-                .<T>map(SerializationUtil::deserialize)
-                .orElseThrow(() -> new IllegalArgumentException("Cannot serialize/deserialize: " + obj));
-    }
-
-    @Test
-    void trySerializeShouldReturnString() {
-        SerializableStringHolder value = new SerializableStringHolder("value");
-
-        String serializedString = "rO0ABXNyAERvcmcuYXBhY2hlLmphbWVzLnV0aWwuU2VyaWFsaXphdGlvblV0aWxUZXN0JFNlcmlhbGl6Y" +
-            "WJsZVN0cmluZ0hvbGRlcjk393aULV9XAgABTAAFdmFsdWV0ABJMamF2YS9sYW5nL1N0cmluZzt4cHQABXZhbHVl";
-
-        String actual = serialize(value);
-
-        assertThat(actual).isEqualTo(serializedString);
-    }
-
-    @Test
-    void roundTripShouldReturnEqualObject() {
-        SerializableStringHolder expected = new SerializableStringHolder("value");
-
-        assertThat(roundtrip(expected)).isEqualTo(expected);
-    }
-
-    @Test
-    void deserializeShouldThrowWhenNotBase64StringProvided() {
-        assertThatExceptionOfType(SerializationException.class)
-                .isThrownBy(() -> deserialize("abc"));
-    }
-
-    @Test
-    void deserializeShouldThrowWhenNotSerializedBytesAreEncodedInBase64() {
-        assertThatExceptionOfType(SerializationException.class)
-                .isThrownBy(() -> deserialize(Base64.getEncoder().encodeToString("abc".getBytes(StandardCharsets.UTF_8))));
-    }
-
-    private static class SerializableStringHolder implements Serializable {
-        private final String value;
-
-        SerializableStringHolder(String value) {
-            this.value = value;
-        }
-
-        @Override
-        public boolean equals(Object o) {
-            if (this == o) {
-                return true;
-            }
-            if (!(o instanceof SerializableStringHolder)) {
-                return false;
-            }
-            SerializableStringHolder that = (SerializableStringHolder) o;
-            return Objects.equals(value, that.value);
-        }
-
-        @Override
-        public int hashCode() {
-            return Objects.hash(value);
-        }
-    }
-}


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


[james-project] 07/15: JAMES-2543 minor cleanups that slipped review

Posted by rc...@apache.org.
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 74332484f2802b712f1e3d40da0ec5602ca21a20
Author: Jean Helou <jh...@codamens.fr>
AuthorDate: Mon Dec 7 09:51:37 2020 +0100

    JAMES-2543 minor cleanups that slipped review
---
 .../main/java/org/apache/james/mpt/smtp/SmtpStarttlsCommandTest.java    | 2 +-
 .../testing/src/main/java/org/apache/james/utils/FakeSmtpExtension.java | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpStarttlsCommandTest.java b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpStarttlsCommandTest.java
index 89925b6..9d25c61 100644
--- a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpStarttlsCommandTest.java
+++ b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpStarttlsCommandTest.java
@@ -35,7 +35,7 @@ public abstract class SmtpStarttlsCommandTest {
     private SimpleScriptedTestProtocol scriptedTest;
 
     @BeforeEach
-    public void setUp(SmtpHostSystem hostSystem) throws Exception {
+    void setUp(SmtpHostSystem hostSystem) throws Exception {
         this.hostSystem = hostSystem;
         String scriptDir = "/org/apache/james/smtp/scripts/";
         scriptedTest = new SimpleScriptedTestProtocol(scriptDir, hostSystem)
diff --git a/server/testing/src/main/java/org/apache/james/utils/FakeSmtpExtension.java b/server/testing/src/main/java/org/apache/james/utils/FakeSmtpExtension.java
index a2f59c3..5eb554d 100644
--- a/server/testing/src/main/java/org/apache/james/utils/FakeSmtpExtension.java
+++ b/server/testing/src/main/java/org/apache/james/utils/FakeSmtpExtension.java
@@ -67,7 +67,7 @@ public class FakeSmtpExtension implements
         return withSmtpPort(SMTP_PORT);
     }
 
-    private static  GenericContainer<?> fakeSmtpContainer() {
+    private static GenericContainer<?> fakeSmtpContainer() {
         return new GenericContainer<>(Images.FAKE_SMTP)
             .waitingFor(new HostPortWaitStrategy()
                 .withRateLimiter(RateLimiters.TWENTIES_PER_SECOND)


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


[james-project] 02/15: JAMES-2884 Mandate core specification

Posted by rc...@apache.org.
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 a0c87b7b351bb4a2805ce13b23a91eee96e4fbbf
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Dec 8 16:40:30 2020 +0700

    JAMES-2884 Mandate core specification
    
    See https://mailarchive.ietf.org/arch/msg/jmap/wQaw_ivbvFtOrEPbkkOkDp3OGrU/
---
 .../jmap/rfc8621/contract/EchoMethodContract.scala  | 21 +++++++++------------
 .../rfc8621/contract/EmailGetMethodContract.scala   |  2 +-
 .../jmap/rfc8621/contract/IdentityGetContract.scala | 14 +++++++-------
 .../rfc8621/contract/MailboxGetMethodContract.scala |  6 +++---
 .../rfc8621/contract/MailboxSetMethodContract.scala |  6 +++---
 .../VacationResponseGetMethodContract.scala         |  2 +-
 .../VacationResponseSetMethodContract.scala         |  2 +-
 .../apache/james/jmap/method/CoreEchoMethod.scala   |  4 ++--
 .../apache/james/jmap/method/EmailGetMethod.scala   |  4 ++--
 .../apache/james/jmap/method/EmailQueryMethod.scala |  4 ++--
 .../apache/james/jmap/method/EmailSetMethod.scala   |  4 ++--
 .../jmap/method/EmailSubmissionSetMethod.scala      |  4 ++--
 .../james/jmap/method/IdentityGetMethod.scala       |  4 ++--
 .../apache/james/jmap/method/MailboxGetMethod.scala |  4 ++--
 .../james/jmap/method/MailboxQueryMethod.scala      |  4 ++--
 .../apache/james/jmap/method/MailboxSetMethod.scala |  4 ++--
 .../apache/james/jmap/method/ThreadGetMethod.scala  |  4 ++--
 .../jmap/method/VacationResponseGetMethod.scala     |  4 ++--
 .../jmap/method/VacationResponseSetMethod.scala     |  4 ++--
 19 files changed, 49 insertions(+), 52 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/EchoMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EchoMethodContract.scala
index 861f632..bf95d32 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EchoMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EchoMethodContract.scala
@@ -130,7 +130,7 @@ trait EchoMethodContract {
   }
 
   @Test
-  def echoMethodShouldNotRequireCapability(): Unit = {
+  def echoMethodShouldReturnUnknownMethodWhenMissingCoreCapability(): Unit = {
     val response = `given`
       .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
       .body(ECHO_REQUEST_OBJECT_WITHOUT_CORE_CAPABILITY)
@@ -145,17 +145,14 @@ trait EchoMethodContract {
 
     assertThatJson(response).isEqualTo(
       s"""{
-         |    "sessionState": "75128aab4b1b",
-         |    "methodResponses": [
-         |        [
-         |            "Core/echo",
-         |            {
-         |                "arg1": "arg1data",
-         |                "arg2": "arg2data"
-         |            },
-         |            "c1"
-         |        ]
-         |    ]
+         |  "sessionState": "75128aab4b1b",
+         |  "methodResponses": [[
+         |    "error",
+         |    {
+         |      "type": "unknownMethod",
+         |      "description": "Missing capability(ies): urn:ietf:params:jmap:core"
+         |    },
+         |    "c1"]]
          |}""".stripMargin)
   }
 }
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/EmailGetMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailGetMethodContract.scala
index ff1eaf8..2be3f41 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailGetMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailGetMethodContract.scala
@@ -3051,7 +3051,7 @@ trait EmailGetMethodContract {
          |    "error",
          |    {
          |      "type": "unknownMethod",
-         |      "description": "Missing capability(ies): urn:ietf:params:jmap:mail"
+         |      "description": "Missing capability(ies): urn:ietf:params:jmap:core, urn:ietf:params:jmap:mail"
          |    },
          |    "c1"]]
          |}""".stripMargin)
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/IdentityGetContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/IdentityGetContract.scala
index b19688a..8f84f84 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/IdentityGetContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/IdentityGetContract.scala
@@ -48,7 +48,7 @@ trait IdentityGetContract {
   def getIdentityShouldReturnDefaultIdentity(): Unit = {
     val request =
       s"""{
-         |  "using": ["urn:ietf:params:jmap:submission"],
+         |  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:submission"],
          |  "methodCalls": [[
          |    "Identity/get",
          |    {
@@ -92,7 +92,7 @@ trait IdentityGetContract {
     server.getProbe(classOf[DataProbeImpl]).addUserAliasMapping("bob-alias", "domain.tld", "bob@domain.tld")
     val request =
       s"""{
-         |  "using": ["urn:ietf:params:jmap:submission"],
+         |  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:submission"],
          |  "methodCalls": [[
          |    "Identity/get",
          |    {
@@ -143,7 +143,7 @@ trait IdentityGetContract {
     server.getProbe(classOf[DataProbeImpl]).addDomainAliasMapping("domain-alias.tld", "domain.tld")
     val request =
       s"""{
-         |  "using": ["urn:ietf:params:jmap:submission"],
+         |  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:submission"],
          |  "methodCalls": [[
          |    "Identity/get",
          |    {
@@ -204,7 +204,7 @@ trait IdentityGetContract {
   def propertiesShouldBeSupported(): Unit = {
     val request =
       s"""{
-         |  "using": ["urn:ietf:params:jmap:submission"],
+         |  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:submission"],
          |  "methodCalls": [[
          |    "Identity/get",
          |    {
@@ -249,7 +249,7 @@ trait IdentityGetContract {
   def propertiesShouldBeFiltered(): Unit = {
     val request =
       s"""{
-         |  "using": ["urn:ietf:params:jmap:submission"],
+         |  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:submission"],
          |  "methodCalls": [[
          |    "Identity/get",
          |    {
@@ -292,7 +292,7 @@ trait IdentityGetContract {
   def badPropertiesShouldBeRejected(): Unit = {
     val request =
       s"""{
-         |  "using": ["urn:ietf:params:jmap:submission"],
+         |  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:submission"],
          |  "methodCalls": [[
          |    "Identity/get",
          |    {
@@ -337,7 +337,7 @@ trait IdentityGetContract {
   def badAccountIdShouldBeRejected(): Unit = {
     val request =
       s"""{
-         |  "using": ["urn:ietf:params:jmap:submission"],
+         |  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:submission"],
          |  "methodCalls": [[
          |    "Identity/get",
          |    {
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/MailboxGetMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxGetMethodContract.scala
index b30d443..843460f 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxGetMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxGetMethodContract.scala
@@ -1455,7 +1455,7 @@ trait MailboxGetMethodContract {
     val response = `given`
       .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
       .body(s"""{
-               |  "using": [ "urn:ietf:params:jmap:core" ],
+               |  "using": [ "urn:ietf:params:jmap:mail" ],
                |  "methodCalls": [[
                |     "Mailbox/get",
                |     {
@@ -1480,7 +1480,7 @@ trait MailboxGetMethodContract {
          |    "error",
          |    {
          |      "type": "unknownMethod",
-         |      "description": "Missing capability(ies): urn:ietf:params:jmap:mail"
+         |      "description": "Missing capability(ies): urn:ietf:params:jmap:core"
          |    },
          |    "c1"]]
          |}""".stripMargin)
@@ -1518,7 +1518,7 @@ trait MailboxGetMethodContract {
          |    "error",
          |    {
          |      "type": "unknownMethod",
-         |      "description": "Missing capability(ies): urn:ietf:params:jmap:mail"
+         |      "description": "Missing capability(ies): urn:ietf:params:jmap:core, urn:ietf:params:jmap:mail"
          |    },
          |    "c1"]]
          |}""".stripMargin)
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/MailboxSetMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
index 881860c..d13058c 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
@@ -7398,7 +7398,7 @@ trait MailboxSetMethodContract {
     val response = `given`
       .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
       .body(s"""{
-               |  "using": [ "urn:ietf:params:jmap:core" ],
+               |  "using": [ "urn:ietf:params:jmap:mail" ],
                |  "methodCalls": [[
                |     "Mailbox/set",
                |     {
@@ -7425,7 +7425,7 @@ trait MailboxSetMethodContract {
          |    "error",
          |    {
          |      "type": "unknownMethod",
-         |      "description": "Missing capability(ies): urn:ietf:params:jmap:mail"
+         |      "description": "Missing capability(ies): urn:ietf:params:jmap:core"
          |    },
          |    "c1"]]
          |}""".stripMargin)
@@ -7465,7 +7465,7 @@ trait MailboxSetMethodContract {
          |    "error",
          |    {
          |      "type": "unknownMethod",
-         |      "description": "Missing capability(ies): urn:ietf:params:jmap:mail"
+         |      "description": "Missing capability(ies): urn:ietf:params:jmap:core, urn:ietf:params:jmap:mail"
          |    },
          |    "c1"]]
          |}""".stripMargin)
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/VacationResponseGetMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/VacationResponseGetMethodContract.scala
index 4572244..cf547d1 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/VacationResponseGetMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/VacationResponseGetMethodContract.scala
@@ -273,7 +273,7 @@ trait VacationResponseGetMethodContract {
          |    "error",
          |    {
          |      "type": "unknownMethod",
-         |      "description":"Missing capability(ies): urn:ietf:params:jmap:vacationresponse"
+         |      "description":"Missing capability(ies): urn:ietf:params:jmap:core, urn:ietf:params:jmap:vacationresponse"
          |    },
          |    "c1"]]
          |}""".stripMargin)
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/VacationResponseSetMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/VacationResponseSetMethodContract.scala
index 570ade4..0b96bf6 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/VacationResponseSetMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/VacationResponseSetMethodContract.scala
@@ -903,7 +903,7 @@ trait VacationResponseSetMethodContract {
          |    "error",
          |    {
          |      "type": "unknownMethod",
-         |      "description": "Missing capability(ies): urn:ietf:params:jmap:vacationresponse"
+         |      "description": "Missing capability(ies): urn:ietf:params:jmap:core, urn:ietf:params:jmap:vacationresponse"
          |    },
          |    "c1"]]
          |}""".stripMargin)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/CoreEchoMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/CoreEchoMethod.scala
index 0c558c1..17afc3d 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/CoreEchoMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/CoreEchoMethod.scala
@@ -20,7 +20,7 @@ package org.apache.james.jmap.method
 
 
 import eu.timepit.refined.auto._
-import org.apache.james.jmap.core.CapabilityIdentifier.CapabilityIdentifier
+import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE}
 import org.apache.james.jmap.core.Invocation.MethodName
 import org.apache.james.mailbox.MailboxSession
 import org.reactivestreams.Publisher
@@ -31,5 +31,5 @@ class CoreEchoMethod extends Method {
 
   override def process(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession): Publisher[InvocationWithContext] = SMono.just(invocation)
 
-  override val requiredCapabilities: Set[CapabilityIdentifier] = Set()
+  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE)
 }
\ No newline at end of file
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailGetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailGetMethod.scala
index a884eaf..e95d711 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailGetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailGetMethod.scala
@@ -23,7 +23,7 @@ import java.time.ZoneId
 import eu.timepit.refined.auto._
 import eu.timepit.refined.types.string.NonEmptyString
 import javax.inject.Inject
-import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_MAIL}
+import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE, JMAP_MAIL}
 import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
 import org.apache.james.jmap.core.State.INSTANCE
 import org.apache.james.jmap.core.{AccountId, ErrorCode, Invocation, Properties}
@@ -80,7 +80,7 @@ class EmailGetMethod @Inject() (readerFactory: EmailViewReaderFactory,
                                 val metricFactory: MetricFactory,
                                 val sessionSupplier: SessionSupplier) extends MethodRequiringAccountId[EmailGetRequest] {
   override val methodName: MethodName = MethodName("Email/get")
-  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_MAIL)
+  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, JMAP_MAIL)
 
   override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: EmailGetRequest): SMono[InvocationWithContext] = {
     computeResponseInvocation(request, invocation.invocation, mailboxSession).onErrorResume({
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailQueryMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailQueryMethod.scala
index 92870b7..e218397 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailQueryMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailQueryMethod.scala
@@ -25,7 +25,7 @@ import eu.timepit.refined.auto._
 import javax.inject.Inject
 import org.apache.james.jmap.JMAPConfiguration
 import org.apache.james.jmap.api.projections.EmailQueryView
-import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_MAIL}
+import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE, JMAP_MAIL}
 import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
 import org.apache.james.jmap.core.Limit.Limit
 import org.apache.james.jmap.core.Position.Position
@@ -53,7 +53,7 @@ class EmailQueryMethod @Inject() (serializer: EmailQuerySerializer,
                                   val configuration: JMAPConfiguration,
                                   val emailQueryView: EmailQueryView) extends MethodRequiringAccountId[EmailQueryRequest] {
   override val methodName: MethodName = MethodName("Email/query")
-  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_MAIL)
+  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, JMAP_MAIL)
 
   override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: EmailQueryRequest): SMono[InvocationWithContext] = {
     processRequest(mailboxSession, invocation.invocation, request, capabilities)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSetMethod.scala
index 0528ac1..4a69b2c 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSetMethod.scala
@@ -20,7 +20,7 @@ package org.apache.james.jmap.method
 
 import eu.timepit.refined.auto._
 import javax.inject.Inject
-import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_MAIL}
+import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE, JMAP_MAIL}
 import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
 import org.apache.james.jmap.core.{ClientId, Id, Invocation, ServerId, State}
 import org.apache.james.jmap.json.{EmailSetSerializer, ResponseSerializer}
@@ -41,7 +41,7 @@ class EmailSetMethod @Inject()(serializer: EmailSetSerializer,
                                deletePerformer: EmailSetDeletePerformer,
                                updatePerformer: EmailSetUpdatePerformer) extends MethodRequiringAccountId[EmailSetRequest] {
   override val methodName: MethodName = MethodName("Email/set")
-  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_MAIL)
+  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, JMAP_MAIL)
 
   override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: EmailSetRequest): SMono[InvocationWithContext] = {
     for {
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala
index 1a8d681..b5791b4 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala
@@ -29,7 +29,7 @@ import javax.mail.Address
 import javax.mail.Message.RecipientType
 import javax.mail.internet.{InternetAddress, MimeMessage}
 import org.apache.james.core.{MailAddress, Username}
-import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, EMAIL_SUBMISSION}
+import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, EMAIL_SUBMISSION, JMAP_CORE}
 import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
 import org.apache.james.jmap.core.SetError.{SetErrorDescription, SetErrorType}
 import org.apache.james.jmap.core.{ClientId, Id, Invocation, Properties, ServerId, SetError, State}
@@ -77,7 +77,7 @@ class EmailSubmissionSetMethod @Inject()(serializer: EmailSubmissionSetSerialize
                                          val metricFactory: MetricFactory,
                                          val sessionSupplier: SessionSupplier) extends MethodRequiringAccountId[EmailSubmissionSetRequest] with Startable {
   override val methodName: MethodName = MethodName("EmailSubmission/set")
-  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(EMAIL_SUBMISSION)
+  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, EMAIL_SUBMISSION)
   var queue: MailQueue = _
 
   sealed trait CreationResult {
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/IdentityGetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/IdentityGetMethod.scala
index c1339bd..3b84038 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/IdentityGetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/IdentityGetMethod.scala
@@ -21,7 +21,7 @@ package org.apache.james.jmap.method
 
 import eu.timepit.refined.auto._
 import javax.inject.Inject
-import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, EMAIL_SUBMISSION}
+import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, EMAIL_SUBMISSION, JMAP_CORE}
 import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
 import org.apache.james.jmap.core.State.INSTANCE
 import org.apache.james.jmap.core._
@@ -38,7 +38,7 @@ class IdentityGetMethod @Inject() (identityFactory: IdentityFactory,
                                   val metricFactory: MetricFactory,
                                   val sessionSupplier: SessionSupplier) extends MethodRequiringAccountId[IdentityGetRequest] {
   override val methodName: MethodName = MethodName("Identity/get")
-  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(EMAIL_SUBMISSION)
+  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, EMAIL_SUBMISSION)
 
   override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: IdentityGetRequest): SMono[InvocationWithContext] = {
     val requestedProperties: Properties = request.properties.getOrElse(Identity.allProperties)
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 1be6614..85a8c6e 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
@@ -21,7 +21,7 @@ package org.apache.james.jmap.method
 
 import eu.timepit.refined.auto._
 import javax.inject.Inject
-import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_MAIL}
+import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE, JMAP_MAIL}
 import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
 import org.apache.james.jmap.core.State.INSTANCE
 import org.apache.james.jmap.core.{AccountId, CapabilityIdentifier, ErrorCode, Invocation, Properties}
@@ -71,7 +71,7 @@ class MailboxGetMethod @Inject() (serializer: MailboxSerializer,
                                   val metricFactory: MetricFactory,
                                   val sessionSupplier: SessionSupplier) extends MethodRequiringAccountId[MailboxGetRequest] {
   override val methodName: MethodName = MethodName("Mailbox/get")
-  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_MAIL)
+  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, JMAP_MAIL)
 
   override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: MailboxGetRequest): SMono[InvocationWithContext] = {
     val requestedProperties: Properties = request.properties.getOrElse(Mailbox.allProperties)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxQueryMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxQueryMethod.scala
index 1c72e21..b19a8af 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxQueryMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxQueryMethod.scala
@@ -20,7 +20,7 @@ package org.apache.james.jmap.method
 
 import eu.timepit.refined.auto._
 import javax.inject.Inject
-import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_MAIL}
+import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE, JMAP_MAIL}
 import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
 import org.apache.james.jmap.core.{CanCalculateChanges, ErrorCode, Invocation, Limit, Position, QueryState}
 import org.apache.james.jmap.json.{MailboxQuerySerializer, ResponseSerializer}
@@ -36,7 +36,7 @@ class MailboxQueryMethod @Inject()(systemMailboxesProvider: SystemMailboxesProvi
                                    val metricFactory: MetricFactory,
                                    val sessionSupplier: SessionSupplier) extends MethodRequiringAccountId[MailboxQueryRequest] {
   override val methodName: MethodName = MethodName("Mailbox/query")
-  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_MAIL)
+  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, JMAP_MAIL)
 
   override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: MailboxQueryRequest): SMono[InvocationWithContext] = {
     processRequest(mailboxSession, invocation.invocation, request)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala
index 467b476..6b6952c 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala
@@ -21,7 +21,7 @@ package org.apache.james.jmap.method
 
 import eu.timepit.refined.auto._
 import javax.inject.Inject
-import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_MAIL}
+import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE, JMAP_MAIL}
 import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
 import org.apache.james.jmap.core.{Invocation, SetError, State}
 import org.apache.james.jmap.json.{MailboxSerializer, ResponseSerializer}
@@ -49,7 +49,7 @@ class MailboxSetMethod @Inject()(serializer: MailboxSerializer,
                                  val metricFactory: MetricFactory,
                                  val sessionSupplier: SessionSupplier) extends MethodRequiringAccountId[MailboxSetRequest] {
   override val methodName: MethodName = MethodName("Mailbox/set")
-  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_MAIL)
+  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, JMAP_MAIL)
 
   override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: MailboxSetRequest): SMono[InvocationWithContext] = for {
     creationResultsWithUpdatedProcessingContext <- createPerformer.createMailboxes(mailboxSession, request, invocation.processingContext)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/ThreadGetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/ThreadGetMethod.scala
index 9e2b6cb..77aed08 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/ThreadGetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/ThreadGetMethod.scala
@@ -21,7 +21,7 @@ package org.apache.james.jmap.method
 
 import eu.timepit.refined.auto._
 import javax.inject.Inject
-import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_MAIL}
+import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE, JMAP_MAIL}
 import org.apache.james.jmap.core.Id.Id
 import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
 import org.apache.james.jmap.core.{Invocation, State}
@@ -36,7 +36,7 @@ import reactor.core.scala.publisher.SMono
 class ThreadGetMethod @Inject()(val metricFactory: MetricFactory,
                                           val sessionSupplier: SessionSupplier) extends MethodRequiringAccountId[ThreadGetRequest] {
   override val methodName: MethodName = MethodName("Thread/get")
-  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_MAIL)
+  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, JMAP_MAIL)
 
   override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: ThreadGetRequest): SMono[InvocationWithContext] = {
     val response = ThreadGetResponse(accountId = request.accountId,
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseGetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseGetMethod.scala
index edb11c2..0bdcb31 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseGetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseGetMethod.scala
@@ -23,7 +23,7 @@ import eu.timepit.refined.auto._
 import javax.inject.Inject
 import org.apache.james.jmap.api.model.{AccountId => JavaAccountId}
 import org.apache.james.jmap.api.vacation.VacationRepository
-import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_VACATION_RESPONSE}
+import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE, JMAP_VACATION_RESPONSE}
 import org.apache.james.jmap.core.Invocation.{Arguments, MethodCallId, MethodName}
 import org.apache.james.jmap.core.State.INSTANCE
 import org.apache.james.jmap.core.{AccountId, ErrorCode, Invocation, MissingCapabilityException, Properties}
@@ -60,7 +60,7 @@ class VacationResponseGetMethod @Inject()(vacationRepository: VacationRepository
                                           val metricFactory: MetricFactory,
                                           val sessionSupplier: SessionSupplier) extends MethodRequiringAccountId[VacationResponseGetRequest] {
   override val methodName: MethodName = MethodName("VacationResponse/get")
-  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_VACATION_RESPONSE)
+  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, JMAP_VACATION_RESPONSE)
 
   override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: VacationResponseGetRequest): SMono[InvocationWithContext] = {
     {
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseSetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseSetMethod.scala
index 8b3e2e3..4f0ff2a 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseSetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseSetMethod.scala
@@ -23,7 +23,7 @@ import eu.timepit.refined.auto._
 import javax.inject.Inject
 import org.apache.james.jmap.api.model.AccountId
 import org.apache.james.jmap.api.vacation.{VacationPatch, VacationRepository}
-import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_VACATION_RESPONSE}
+import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE, JMAP_MAIL, JMAP_VACATION_RESPONSE}
 import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
 import org.apache.james.jmap.core.SetError.SetErrorDescription
 import org.apache.james.jmap.core.{Invocation, State}
@@ -74,7 +74,7 @@ class VacationResponseSetMethod @Inject()(vacationRepository: VacationRepository
                                           val metricFactory: MetricFactory,
                                           val sessionSupplier: SessionSupplier) extends MethodRequiringAccountId[VacationResponseSetRequest] {
   override val methodName: MethodName = MethodName("VacationResponse/set")
-  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_VACATION_RESPONSE)
+  override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, JMAP_VACATION_RESPONSE)
 
   override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: VacationResponseSetRequest): SMono[InvocationWithContext] = {
     update(mailboxSession, request)


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


[james-project] 09/15: [REFACTORING] StoreMailboxManager: limit visibility of getters where possible

Posted by rc...@apache.org.
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 0b2b11ed10171d72f53edc1ea4abd518a10b2f62
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sun Dec 6 21:37:21 2020 +0700

    [REFACTORING] StoreMailboxManager: limit visibility of getters where possible
---
 .../java/org/apache/james/mailbox/store/StoreMailboxManager.java  | 8 ++++----
 1 file changed, 4 insertions(+), 4 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 28cf6b8..ddf6b07 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
@@ -199,7 +199,7 @@ public class StoreMailboxManager implements MailboxManager {
     /**
      * Return the {@link MessageSearchIndex} used by this {@link MailboxManager}
      */
-    public MessageSearchIndex getMessageSearchIndex() {
+    protected MessageSearchIndex getMessageSearchIndex() {
         return index;
     }
 
@@ -210,7 +210,7 @@ public class StoreMailboxManager implements MailboxManager {
         return mailboxSessionMapperFactory;
     }
 
-    public MailboxPathLocker getLocker() {
+    protected MailboxPathLocker getLocker() {
         return locker;
     }
 
@@ -218,11 +218,11 @@ public class StoreMailboxManager implements MailboxManager {
         return storeRightManager;
     }
 
-    public MessageParser getMessageParser() {
+    protected MessageParser getMessageParser() {
         return messageParser;
     }
 
-    public PreDeletionHooks getPreDeletionHooks() {
+    protected PreDeletionHooks getPreDeletionHooks() {
         return preDeletionHooks;
     }
 


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


[james-project] 13/15: [REFACTORING] Remove unused MailboxIdDeserializer class

Posted by rc...@apache.org.
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 9386502947f7877343acd0964d641ca18668ff23
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sun Dec 6 22:02:30 2020 +0700

    [REFACTORING] Remove unused MailboxIdDeserializer class
    
    This is now handled by the MailboxId.Factory class
---
 .../ids/CassandraMailboxIdDeserializer.java        | 38 ---------------
 .../ids/CassandraMailboxIdDeserializerTest.java    | 55 ---------------------
 .../mailbox/jpa/JPAMailboxIdDeserializer.java      | 35 --------------
 .../main/resources/META-INF/spring/mailbox-jpa.xml |  2 -
 .../mailbox/jpa/JPAMailboxIdDeserializerTest.java  | 53 --------------------
 .../maildir/MaildirMailboxIdDeserializer.java      | 35 --------------
 .../resources/META-INF/spring/mailbox-maildir.xml  |  2 -
 .../maildir/MaildirMailboxIdDeserializerTest.java  | 56 ----------------------
 .../inmemory/InMemoryMailboxIdDeserializer.java    | 36 --------------
 .../resources/META-INF/spring/mailbox-memory.xml   |  2 -
 .../InMemoryMailboxIdDeserializerTest.java         | 54 ---------------------
 .../store/mail/model/MailboxIdDeserializer.java    | 28 -----------
 12 files changed, 396 deletions(-)

diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/ids/CassandraMailboxIdDeserializer.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/ids/CassandraMailboxIdDeserializer.java
deleted file mode 100644
index 96fc17c..0000000
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/ids/CassandraMailboxIdDeserializer.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mailbox.cassandra.ids;
-
-import java.util.UUID;
-
-import org.apache.james.mailbox.store.mail.model.MailboxIdDeserialisationException;
-import org.apache.james.mailbox.store.mail.model.MailboxIdDeserializer;
-
-public class CassandraMailboxIdDeserializer implements MailboxIdDeserializer {
-
-    @Override
-    public CassandraId deserialize(String serializedMailboxId) throws MailboxIdDeserialisationException {
-        try {
-            return CassandraId.of(UUID.fromString(serializedMailboxId));
-        } catch (Exception e) {
-            throw new MailboxIdDeserialisationException("Error de-serialising " + serializedMailboxId, e);
-        }
-    }
-
-}
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/ids/CassandraMailboxIdDeserializerTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/ids/CassandraMailboxIdDeserializerTest.java
deleted file mode 100644
index 597f529..0000000
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/ids/CassandraMailboxIdDeserializerTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mailbox.cassandra.ids;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import java.util.UUID;
-
-import org.apache.james.mailbox.store.mail.model.MailboxIdDeserialisationException;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-class CassandraMailboxIdDeserializerTest {
-
-    private static final String UUID_STRING = "5530370f-44c6-4647-990e-7768ce5131d4";
-    private static final String MALFORMED_UUID_STRING = "xyz";
-    private static final CassandraId CASSANDRA_ID = CassandraId.of(UUID.fromString(UUID_STRING));
-
-    private CassandraMailboxIdDeserializer mailboxIdDeserializer;
-
-    @BeforeEach
-    void setUp() {
-        mailboxIdDeserializer = new CassandraMailboxIdDeserializer();
-    }
-
-    @Test
-    void deserializeShouldWork() throws Exception {
-        assertThat(mailboxIdDeserializer.deserialize(UUID_STRING)).isEqualTo(CASSANDRA_ID);
-    }
-
-    @Test
-    void deserializeShouldThrowOnMalformedData() {
-        assertThatThrownBy(() -> mailboxIdDeserializer.deserialize(MALFORMED_UUID_STRING))
-            .isInstanceOf(MailboxIdDeserialisationException.class);
-    }
-
-}
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxIdDeserializer.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxIdDeserializer.java
deleted file mode 100644
index 9e4f7d6..0000000
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxIdDeserializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mailbox.jpa;
-
-import org.apache.james.mailbox.store.mail.model.MailboxIdDeserialisationException;
-import org.apache.james.mailbox.store.mail.model.MailboxIdDeserializer;
-
-public class JPAMailboxIdDeserializer implements MailboxIdDeserializer {
-
-    @Override
-    public JPAId deserialize(String serializedMailboxId) throws MailboxIdDeserialisationException {
-        try {
-            return JPAId.of(Long.parseLong(serializedMailboxId));
-        } catch (Exception e) {
-            throw new MailboxIdDeserialisationException("Error deserializing " + serializedMailboxId, e);
-        }
-    }
-}
diff --git a/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml b/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml
index 8dd4aba..fb646fc 100644
--- a/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml
+++ b/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml
@@ -87,8 +87,6 @@
         <property name="showSql" value="false"/>
     </bean>
 
-    <bean id="jpa-mailbox-id-deserializer" class="org.apache.james.mailbox.jpa.JPAMailboxIdDeserializer"/>
-
     <bean id="jpa-per-user-max-quota-dao" class="org.apache.james.mailbox.jpa.quota.JPAPerUserMaxQuotaDAO">
         <constructor-arg index="0" ref="entityManagerFactory"/>
     </bean>
diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxIdDeserializerTest.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxIdDeserializerTest.java
deleted file mode 100644
index 1ad1d88..0000000
--- a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxIdDeserializerTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mailbox.jpa;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import org.apache.james.mailbox.store.mail.model.MailboxIdDeserialisationException;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-class JPAMailboxIdDeserializerTest {
-
-    static final String SERIALIZED_ID = "123456789012";
-    static final String MALFORMED_SERIALIZED_ID = "abcz";
-    static final JPAId JPA_ID = JPAId.of(Long.parseLong(SERIALIZED_ID));
-
-    JPAMailboxIdDeserializer mailboxIdDeserializer;
-
-    @BeforeEach
-    void setUp() {
-        mailboxIdDeserializer = new JPAMailboxIdDeserializer();
-    }
-
-    @Test
-    void deserializeShouldWork() throws Exception {
-        assertThat(mailboxIdDeserializer.deserialize(SERIALIZED_ID)).isEqualTo(JPA_ID);
-    }
-
-    @Test
-    void deserializeShouldThrowOnMalformedData() {
-        assertThatThrownBy(() -> mailboxIdDeserializer.deserialize(MALFORMED_SERIALIZED_ID))
-            .isInstanceOf(MailboxIdDeserialisationException.class);
-    }
-
-}
diff --git a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxIdDeserializer.java b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxIdDeserializer.java
deleted file mode 100644
index 088b5b8..0000000
--- a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxIdDeserializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mailbox.maildir;
-
-import org.apache.james.mailbox.store.mail.model.MailboxIdDeserialisationException;
-import org.apache.james.mailbox.store.mail.model.MailboxIdDeserializer;
-
-public class MaildirMailboxIdDeserializer implements MailboxIdDeserializer {
-
-    @Override
-    public MaildirId deserialize(String serializedMailboxId) throws MailboxIdDeserialisationException {
-        try {
-            return MaildirId.fromString(serializedMailboxId);
-        } catch (Exception e) {
-            throw new MailboxIdDeserialisationException("Can not deserialize " + serializedMailboxId, e);
-        }
-    }
-}
diff --git a/mailbox/maildir/src/main/resources/META-INF/spring/mailbox-maildir.xml b/mailbox/maildir/src/main/resources/META-INF/spring/mailbox-maildir.xml
index 6ebdc31..50adf609 100644
--- a/mailbox/maildir/src/main/resources/META-INF/spring/mailbox-maildir.xml
+++ b/mailbox/maildir/src/main/resources/META-INF/spring/mailbox-maildir.xml
@@ -63,6 +63,4 @@
     </bean>
     <alias name="jvm-locker" alias="maildir-locker"/>
 
-    <bean id="maildir-mailbox-id-deserializer" class="org.apache.james.mailbox.maildir.MaildirMailboxIdDeserializer"/>
-
 </beans>
diff --git a/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxIdDeserializerTest.java b/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxIdDeserializerTest.java
deleted file mode 100644
index bed406b..0000000
--- a/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxIdDeserializerTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mailbox.maildir;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import java.util.UUID;
-
-import org.apache.james.mailbox.store.mail.model.MailboxIdDeserialisationException;
-import org.apache.james.mailbox.store.mail.model.MailboxIdDeserializer;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-class MaildirMailboxIdDeserializerTest {
-
-    static final String SERIALIZED_ID = "2f3a4fcc-ca64-36e3-9bcf-33e92dd93135";
-    static final String MALFORMED_SERIALIZED_ID = "az";
-    static final MaildirId MAILDIR_ID = MaildirId.of(UUID.fromString(SERIALIZED_ID));
-
-    MailboxIdDeserializer mailboxIdDeserializer;
-
-    @BeforeEach
-    void setUp() {
-        mailboxIdDeserializer = new MaildirMailboxIdDeserializer();
-    }
-
-    @Test
-    void deserializeShouldWork() throws Exception {
-        assertThat(mailboxIdDeserializer.deserialize(SERIALIZED_ID)).isEqualTo(MAILDIR_ID);
-    }
-
-    @Test
-    void deserializeShouldThrowOnMalformedData() {
-        assertThatThrownBy(() -> mailboxIdDeserializer.deserialize(MALFORMED_SERIALIZED_ID))
-            .isInstanceOf(MailboxIdDeserialisationException.class);
-    }
-
-}
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxIdDeserializer.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxIdDeserializer.java
deleted file mode 100644
index 0530a1a..0000000
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxIdDeserializer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mailbox.inmemory;
-
-import org.apache.james.mailbox.store.mail.model.MailboxIdDeserialisationException;
-import org.apache.james.mailbox.store.mail.model.MailboxIdDeserializer;
-
-public class InMemoryMailboxIdDeserializer implements MailboxIdDeserializer {
-
-    @Override
-    public InMemoryId deserialize(String serializedMailboxId) throws MailboxIdDeserialisationException {
-        try {
-            return InMemoryId.of(Long.parseLong(serializedMailboxId));
-        } catch (Exception e) {
-            throw new MailboxIdDeserialisationException("Error deserializing " + serializedMailboxId, e);
-        }
-    }
-
-}
diff --git a/mailbox/memory/src/main/resources/META-INF/spring/mailbox-memory.xml b/mailbox/memory/src/main/resources/META-INF/spring/mailbox-memory.xml
index 2d31f25..c701d67 100644
--- a/mailbox/memory/src/main/resources/META-INF/spring/mailbox-memory.xml
+++ b/mailbox/memory/src/main/resources/META-INF/spring/mailbox-memory.xml
@@ -53,6 +53,4 @@
 
     <alias name="jvm-locker" alias="memory-locker"/>
 
-    <bean id="memory-mailbox-id-deserializer" class="org.apache.james.mailbox.inmemory.InMemoryMailboxIdDeserializer"/>
-
 </beans>
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxIdDeserializerTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxIdDeserializerTest.java
deleted file mode 100644
index d0f83bc..0000000
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxIdDeserializerTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mailbox.inmemory;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import org.apache.james.mailbox.store.mail.model.MailboxIdDeserialisationException;
-import org.apache.james.mailbox.store.mail.model.MailboxIdDeserializer;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-class InMemoryMailboxIdDeserializerTest {
-
-    static final String SERIALIZED_ID = "1234567890123";
-    static final String MALFORMED_SERIALIZED_ID = "aEZ";
-    static final InMemoryId IN_MEMORY_ID = InMemoryId.of(Long.parseLong(SERIALIZED_ID));
-
-    MailboxIdDeserializer mailboxIdDeserializer;
-
-    @BeforeEach
-    void setUp() {
-        mailboxIdDeserializer = new InMemoryMailboxIdDeserializer();
-    }
-
-    @Test
-    void deserializeShouldWork() throws MailboxIdDeserialisationException {
-        assertThat(mailboxIdDeserializer.deserialize(SERIALIZED_ID)).isEqualTo(IN_MEMORY_ID);
-    }
-
-    @Test
-    void deserializeShouldThrowOnMalformedData() {
-        assertThatThrownBy(() -> mailboxIdDeserializer.deserialize(MALFORMED_SERIALIZED_ID))
-            .isInstanceOf(MailboxIdDeserialisationException.class);
-    }
-
-}
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxIdDeserializer.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxIdDeserializer.java
deleted file mode 100644
index 864be74..0000000
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxIdDeserializer.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mailbox.store.mail.model;
-
-import org.apache.james.mailbox.model.MailboxId;
-
-public interface MailboxIdDeserializer {
-
-    MailboxId deserialize(String serializedMailboxId) throws MailboxIdDeserialisationException;
-
-}


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


[james-project] 06/15: JAMES-2578 Document upgrade-instructions

Posted by rc...@apache.org.
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 ac24814d31d01d0879642819a11285375a2ff8a6
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Dec 7 14:55:38 2020 +0700

    JAMES-2578 Document upgrade-instructions
---
 upgrade-instructions.md | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/upgrade-instructions.md b/upgrade-instructions.md
index 7918bea..dca2f21 100644
--- a/upgrade-instructions.md
+++ b/upgrade-instructions.md
@@ -22,6 +22,27 @@ Change list:
  - [Swift support has been dropped](#swift-support-has-been-dropped)
  - [Cassandra Schema update to V8](#cassandra-schema-update-to-v8)
  - [Cassandra Schema update to V9](#cassandra-schema-update-to-v9)
+ - [Cassandra Schema update to V10](#cassandra-schema-update-to-v10)
+ - [JMS mail queue no longer relies on java serialization](#jms-mail-queue-no-longer-relies-on-java-serialization)
+
+### JMS mail queue no longer relies on java serialization
+
+Date: 07/12/2020
+
+JIRA: https://issues.apache.org/jira/browse/JAMES-2578
+
+Concerned products: Spring server, JPA Guice servers, Cassandra Guice server (without rabbitMQ)
+
+Java serialization is unsafe and leads to countless vulnerability issues. We removed the remaining usages as part of the
+JMS and ActiveMQ mail queues.
+
+In order to do so, we introduced a breaking change in the message format.
+
+Upgrades should be done with an empty mail queue. To do so:
+ - Switch off incoming SMTP + JMAP traffic (external load balancing or restarting with dis-activated SMTP service)
+ - Flush your MailQueues
+ - Await the mail processing to finish, monitoring the size of your mail queue
+ - Upgrade, then restart SMTP + JMAP traffic
 
 ### Cassandra Schema update to V10
 


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