Repository: james-project
Updated Branches:
  refs/heads/master 67e44d268 -> 6bd459a86


JAMES-2122 Adding a log on swallowed expunge

This makes us aware of some denormalisation issues


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/a27e73a2
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/a27e73a2
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/a27e73a2

Branch: refs/heads/master
Commit: a27e73a2e83429bb4203e40e0be7cff96caaeb57
Parents: 67e44d2
Author: benwa <btell...@linagora.com>
Authored: Thu Aug 17 09:42:35 2017 +0700
Committer: Matthieu Baechler <matth...@apache.org>
Committed: Thu Aug 17 13:12:31 2017 +0200

----------------------------------------------------------------------
 .../cassandra/mail/CassandraMessageMapper.java       | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/a27e73a2/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
----------------------------------------------------------------------
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 e782127..eda305b 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
@@ -39,9 +39,9 @@ import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
 import org.apache.james.mailbox.cassandra.ids.CassandraMessageId;
-import org.apache.james.mailbox.cassandra.mail.utils.Limit;
 import org.apache.james.mailbox.cassandra.mail.migration.V1ToV2Migration;
 import org.apache.james.mailbox.cassandra.mail.utils.FlagsUpdateStageResult;
+import org.apache.james.mailbox.cassandra.mail.utils.Limit;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.ComposedMessageId;
 import org.apache.james.mailbox.model.ComposedMessageIdWithMetaData;
@@ -196,8 +196,6 @@ public class CassandraMessageMapper implements 
MessageMapper {
             .thenCompose(stream -> 
attachmentLoader.addAttachmentToMessages(stream, fetchType));
     }
 
-
-
     @Override
     public List<MessageUid> findRecentMessageUidsInMailbox(Mailbox mailbox) 
throws MailboxException {
         CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
@@ -228,13 +226,22 @@ public class CassandraMessageMapper implements 
MessageMapper {
 
     private CompletableFuture<Stream<SimpleMailboxMessage>> 
expungeUidChunk(CassandraId mailboxId, Collection<MessageUid> uidChunk) {
         return FluentFutureStream.ofOptionals(
-                uidChunk.stream().map(uid -> messageIdDAO.retrieve(mailboxId, 
uid)))
+                uidChunk.stream().map(uid -> retrieveComposedId(mailboxId, 
uid)))
             .performOnAll(this::deleteUsingMailboxId)
             .thenFlatCompose(idWithMetadata -> 
retrieveMessagesAndDoMigrationIfNeeded(ImmutableList.of(idWithMetadata), 
FetchType.Metadata, Limit.unlimited()))
             .map(pair -> pair.getKey().toMailboxMessage(ImmutableList.of()))
             .completableFuture();
     }
 
+    private CompletableFuture<Optional<ComposedMessageIdWithMetaData>> 
retrieveComposedId(CassandraId mailboxId, MessageUid uid) {
+        return messageIdDAO.retrieve(mailboxId, uid)
+            .thenApply(value -> Optional.of(value)
+            .orElseGet(() -> {
+                LOGGER.warn("Could not retrieve message {} {}", mailboxId, 
uid);
+                return Optional.empty();
+            }));
+    }
+
     private CompletableFuture<Stream<Pair<MessageWithoutAttachment, 
Stream<MessageAttachmentRepresentation>>>> 
retrieveMessagesAndDoMigrationIfNeeded(
         List<ComposedMessageIdWithMetaData> messageIds, FetchType fetchType, 
Limit limit) {
 


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

Reply via email to