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 2024/03/07 02:22:49 UTC
(james-project) branch master updated (b2a4e250b6 -> 5c40b2dd72)
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 b2a4e250b6 JAMES-3419 JMAP EmailBodyPart individual headers - Fix test cases
new c274b412e1 [IMPROVE] SelectedMailboxImpl: extract isFromOtherSession
new 59323cb54a [IMPROVE] SelectedMailboxImpl: remove double space
new 10b6197c07 [IMPROVE] SelectedMailboxImpl: remove unused method
new 6cf53137d5 [IMPROVE] SelectedMailboxImpl: simplify RECENT flag event handling
new da97a137f4 [IMPROVE] SelectedMailboxImpl: checkExpungedRecents should avoid a data copy
new 9bafec0227 [IMPROVE] SelectedMailboxImpl: simplify RECENT flag event handling upon addition
new 9698d580d7 [IMPROVE] SelectedMailboxImpl: IMAP session is not needed
new 4db213893c [IMPROVE] Remove unused class SingleMessageResultIterator
new 5c40b2dd72 [FIX] SelectedMailboxImpl: using Mono defer to avoid eager invoke idleEventListener
The 9 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:
.../imap/processor/AbstractSelectionProcessor.java | 2 +-
.../imap/processor/base/SelectedMailboxImpl.java | 73 +++++++---------------
.../james/imap/processor/base/UidMsnConverter.java | 13 ++--
.../processor/base/MailboxEventAnalyserTest.java | 39 +-----------
.../processor/base/SelectedMailboxImplTest.java | 12 ++--
5 files changed, 35 insertions(+), 104 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
(james-project) 04/09: [IMPROVE] SelectedMailboxImpl: simplify RECENT flag event handling
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 6cf53137d540ee518468dc9987d0399e9c80c597
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Mon Mar 4 07:56:24 2024 +0100
[IMPROVE] SelectedMailboxImpl: simplify RECENT flag event handling
- Explicitly work on current SelectedMailboxImpl
- MailboxId condition was already checked
- Avoid while loop
---
.../imap/processor/base/SelectedMailboxImpl.java | 26 +++++++---------------
1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
index 4449027383..aace0e0af7 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
@@ -444,24 +444,14 @@ public class SelectedMailboxImpl implements SelectedMailbox, EventListener.React
}
}
- SelectedMailbox sm = session.getSelected();
- if (sm != null) {
- // We need to add the UID of the message to the recent
- // list if we receive an flag update which contains a
- // \RECENT flag
- // See IMAP-287
- List<UpdatedFlags> uflags = updated.getUpdatedFlags();
- for (UpdatedFlags u : uflags) {
- Iterator<Flag> flags = u.modifiedSystemFlags().iterator();
-
- while (flags.hasNext()) {
- if (Flag.RECENT.equals(flags.next())) {
- MailboxId id = sm.getMailboxId();
- if (id != null && id.equals(updated.getMailboxId())) {
- sm.addRecent(u.getUid());
- }
- }
- }
+ // We need to add the UID of the message to the recent
+ // list if we receive an flag update which contains a
+ // \RECENT flag
+ // See IMAP-287
+ List<UpdatedFlags> uflags = updated.getUpdatedFlags();
+ for (UpdatedFlags u : uflags) {
+ if (u.modifiedSystemFlags().contains(Flag.RECENT)) {
+ recentUids.add(u.getUid());
}
}
long stamp = applicableFlagsLock.writeLock();
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
(james-project) 05/09: [IMPROVE] SelectedMailboxImpl: checkExpungedRecents should avoid a data copy
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 da97a137f43ce1c03413388678bcfb5ada02f2b5
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Mon Mar 4 07:57:12 2024 +0100
[IMPROVE] SelectedMailboxImpl: checkExpungedRecents should avoid a data copy
Working on the inner structure is safe as we are in
critical section already
---
.../java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
index aace0e0af7..b54977294a 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
@@ -255,7 +255,7 @@ public class SelectedMailboxImpl implements SelectedMailbox, EventListener.React
}
private void checkExpungedRecents() {
- for (MessageUid uid : expungedUids()) {
+ for (MessageUid uid : expungedUids) {
removeRecent(uid);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
(james-project) 02/09: [IMPROVE] SelectedMailboxImpl: remove double space
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 59323cb54a1b8a1ca6a5a57618754061700ee4e9
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Mon Mar 4 07:54:19 2024 +0100
[IMPROVE] SelectedMailboxImpl: remove double space
---
.../java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
index 6d05fb76aa..974627ba69 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
@@ -218,7 +218,7 @@ public class SelectedMailboxImpl implements SelectedMailbox, EventListener.React
}
@Override
- public synchronized boolean removeRecent(MessageUid uid) {
+ public synchronized boolean removeRecent(MessageUid uid) {
final boolean result = recentUids.remove(uid);
if (result) {
recentUidRemoved.set(true);
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
(james-project) 06/09: [IMPROVE] SelectedMailboxImpl: simplify RECENT flag event handling upon addition
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 9bafec022759c1c0658b39a16cac79f93034b493
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Mon Mar 4 11:58:41 2024 +0100
[IMPROVE] SelectedMailboxImpl: simplify RECENT flag event handling upon addition
---
.../james/imap/processor/base/SelectedMailboxImpl.java | 9 ++-------
.../apache/james/imap/processor/base/UidMsnConverter.java | 13 +++++++------
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
index b54977294a..c73ecdba56 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
@@ -462,13 +462,8 @@ public class SelectedMailboxImpl implements SelectedMailbox, EventListener.React
private Void handleAddition(Added added) {
sizeChanged.set(true);
- SelectedMailbox sm = session.getSelected();
- for (MessageUid uid : added.getUids()) {
- uidMsnConverter.addUid(uid);
- if (sm != null) {
- sm.addRecent(uid);
- }
- }
+ uidMsnConverter.addAll(added.getUids());
+ recentUids.addAll(added.getUids());
return VOID;
}
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/UidMsnConverter.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/UidMsnConverter.java
index b4cc4bbf61..9716946f2c 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/UidMsnConverter.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/UidMsnConverter.java
@@ -20,6 +20,7 @@
package org.apache.james.imap.processor.base;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import java.util.Optional;
@@ -49,11 +50,11 @@ public class UidMsnConverter {
this.uidsAsInts = new IntArrayList();
}
- public synchronized void addAll(List<MessageUid> addedUids) {
+ public synchronized void addAll(Collection<MessageUid> addedUids) {
addAllUnSynchronized(addedUids);
}
- private void addAllUnSynchronized(List<MessageUid> addedUids) {
+ private void addAllUnSynchronized(Collection<MessageUid> addedUids) {
if (usesInts) {
if (uidsAsInts.isEmpty()) {
// Avoids intermediary tree structure
@@ -71,7 +72,7 @@ public class UidMsnConverter {
}
}
- private void addAllToNonEmptyLongStructure(List<MessageUid> addedUids) {
+ private void addAllToNonEmptyLongStructure(Collection<MessageUid> addedUids) {
LongAVLTreeSet tmp = new LongAVLTreeSet(uids);
for (MessageUid uid : addedUids) {
tmp.add(uid.asLong());
@@ -80,7 +81,7 @@ public class UidMsnConverter {
uids.addAll(tmp);
}
- private void addAllToEmptyLongStructure(List<MessageUid> addedUids) {
+ private void addAllToEmptyLongStructure(Collection<MessageUid> addedUids) {
uids.ensureCapacity(addedUids.size());
for (MessageUid uid : addedUids) {
uids.add(uid.asLong());
@@ -88,7 +89,7 @@ public class UidMsnConverter {
uids.sort(LongComparators.NATURAL_COMPARATOR);
}
- private void addAllToNonEmptyIntStructure(List<MessageUid> addedUids) {
+ private void addAllToNonEmptyIntStructure(Collection<MessageUid> addedUids) {
IntAVLTreeSet tmp = new IntAVLTreeSet(uidsAsInts);
for (MessageUid uid : addedUids) {
if (uid.asLong() > INTEGER_MAX_VALUE) {
@@ -102,7 +103,7 @@ public class UidMsnConverter {
uidsAsInts.addAll(tmp);
}
- private void addAllToEmptyIntStructure(List<MessageUid> addedUids) {
+ private void addAllToEmptyIntStructure(Collection<MessageUid> addedUids) {
uidsAsInts.ensureCapacity(addedUids.size());
for (MessageUid uid : addedUids) {
if (uid.asLong() > INTEGER_MAX_VALUE) {
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
(james-project) 07/09: [IMPROVE] SelectedMailboxImpl: IMAP session is not needed
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 9698d580d7376353cb4487ce0b44cf43b0182fb4
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Mon Mar 4 12:05:53 2024 +0100
[IMPROVE] SelectedMailboxImpl: IMAP session is not needed
---
.../james/imap/processor/AbstractSelectionProcessor.java | 2 +-
.../james/imap/processor/base/SelectedMailboxImpl.java | 7 ++-----
.../james/imap/processor/base/MailboxEventAnalyserTest.java | 5 +----
.../james/imap/processor/base/SelectedMailboxImplTest.java | 12 ++++--------
4 files changed, 8 insertions(+), 18 deletions(-)
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
index 38b66816ee..fb5153ff08 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
@@ -420,7 +420,7 @@ abstract class AbstractSelectionProcessor<R extends AbstractMailboxSelectionRequ
responder.respond(getStatusResponseFactory()
.untaggedOk(HumanReadableText.QRESYNC_CLOSED, ResponseCode.closed()));
}
- SelectedMailboxImpl selectedMailbox = new SelectedMailboxImpl(getMailboxManager(), eventBus, session, mailbox);
+ SelectedMailboxImpl selectedMailbox = new SelectedMailboxImpl(getMailboxManager(), eventBus, session.getMailboxSession(), mailbox);
return session.selected(selectedMailbox)
.then(selectedMailbox.finishInit())
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
index c73ecdba56..ce035a2a76 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
@@ -42,7 +42,6 @@ import org.apache.james.events.Event;
import org.apache.james.events.EventBus;
import org.apache.james.events.EventListener;
import org.apache.james.events.Registration;
-import org.apache.james.imap.api.process.ImapSession;
import org.apache.james.imap.api.process.SelectedMailbox;
import org.apache.james.mailbox.FlagsBuilder;
import org.apache.james.mailbox.MailboxManager;
@@ -126,7 +125,6 @@ public class SelectedMailboxImpl implements SelectedMailbox, EventListener.React
private final MessageManager messageManager;
private final MailboxId mailboxId;
private final EventBus eventBus;
- private final ImapSession session;
private final MailboxSession mailboxSession;
private final UidMsnConverter uidMsnConverter;
private final Set<MessageUid> recentUids = new TreeSet<>();
@@ -140,12 +138,11 @@ public class SelectedMailboxImpl implements SelectedMailbox, EventListener.React
private final AtomicBoolean silentFlagChanges = new AtomicBoolean(false);
private ApplicableFlags applicableFlags = ApplicableFlags.from(new Flags());
- public SelectedMailboxImpl(MailboxManager mailboxManager, EventBus eventBus, ImapSession session, MessageManager messageManager) {
+ public SelectedMailboxImpl(MailboxManager mailboxManager, EventBus eventBus, MailboxSession session, MessageManager messageManager) {
this.eventBus = eventBus;
- this.session = session;
this.mailboxManager = mailboxManager;
this.messageManager = messageManager;
- this.mailboxSession = session.getMailboxSession();
+ this.mailboxSession = session;
this.uidMsnConverter = new UidMsnConverter();
this.mailboxId = messageManager.getId();
}
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
index 5b7de54a0b..06ae218023 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
@@ -142,10 +142,7 @@ class MailboxEventAnalyserTest {
@BeforeEach
void setUp() throws MailboxException {
- FakeImapSession imapSession = new FakeImapSession();
InVMEventBus eventBus = new InVMEventBus(new InVmEventDelivery(new RecordingMetricFactory()), EventBusTestFixture.RETRY_BACKOFF_CONFIGURATION, new MemoryEventDeadLetters());
- imapSession.setMailboxSession(MAILBOX_SESSION);
- imapSession.authenticated();
MailboxManager mailboxManager = mock(MailboxManager.class);
MessageManager messageManager = mock(MessageManager.class);
@@ -167,7 +164,7 @@ class MailboxEventAnalyserTest {
when(messageManager.getMessagesReactive(any(), any(), any()))
.thenReturn(Flux.just(messageResult));
- testee = new SelectedMailboxImpl(mailboxManager, eventBus, imapSession, messageManager);
+ testee = new SelectedMailboxImpl(mailboxManager, eventBus, MAILBOX_SESSION, messageManager);
testee.finishInit().block();
}
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java
index 79b1369be7..c9ff3339e6 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java
@@ -97,7 +97,6 @@ class SelectedMailboxImplTest {
private MailboxManager mailboxManager;
private MessageManager messageManager;
private MailboxPath mailboxPath;
- private FakeImapSession imapSession;
private Mailbox mailbox;
private TestId mailboxId;
private EventBus eventBus;
@@ -110,7 +109,6 @@ class SelectedMailboxImplTest {
mailboxPath = MailboxPath.inbox(Username.of("tellier@linagora.com"));
mailboxManager = mock(MailboxManager.class);
messageManager = mock(MessageManager.class);
- imapSession = new FakeImapSession();
mailbox = mock(Mailbox.class);
mailboxId = TestId.of(42);
mailboxIdRegistrationKey = new MailboxIdRegistrationKey(mailboxId);
@@ -125,8 +123,6 @@ class SelectedMailboxImplTest {
.delayElements(Duration.ofSeconds(1)));
when(messageManager.getId()).thenReturn(mailboxId);
- imapSession.setMailboxSession(mock(MailboxSession.class));
-
when(mailbox.generateAssociatedPath()).thenReturn(mailboxPath);
when(mailbox.getMailboxId()).thenReturn(mailboxId);
}
@@ -145,7 +141,7 @@ class SelectedMailboxImplTest {
SelectedMailboxImpl selectedMailbox = new SelectedMailboxImpl(
mailboxManager,
eventBus,
- imapSession,
+ mock(MailboxSession.class),
messageManager);
selectedMailbox.finishInit().block();
@@ -159,7 +155,7 @@ class SelectedMailboxImplTest {
.when(eventBus)
.register(any(EventListener.ReactiveEventListener.class), eq(mailboxIdRegistrationKey));
- new SelectedMailboxImpl(mailboxManager, eventBus, imapSession, messageManager).finishInit().block();
+ new SelectedMailboxImpl(mailboxManager, eventBus, mock(MailboxSession.class), messageManager).finishInit().block();
assertThat(successCount.get()).isEqualTo(1);
}
@@ -171,7 +167,7 @@ class SelectedMailboxImplTest {
.when(eventBus)
.register(any(EventListener.ReactiveEventListener.class), eq(mailboxIdRegistrationKey));
- SelectedMailboxImpl selectedMailbox = new SelectedMailboxImpl(mailboxManager, eventBus, imapSession, messageManager);
+ SelectedMailboxImpl selectedMailbox = new SelectedMailboxImpl(mailboxManager, eventBus, mock(MailboxSession.class), messageManager);
selectedMailbox.finishInit().block();
assertThat(selectedMailbox.getApplicableFlags().getUserFlags()).containsOnly(CUSTOM_FLAG);
@@ -187,7 +183,7 @@ class SelectedMailboxImplTest {
new SelectedMailboxImpl(
mailboxManager,
eventBus,
- imapSession,
+ mock(MailboxSession.class),
messageManager).finishInit().block();
assertThat(successCount.get())
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
(james-project) 08/09: [IMPROVE] Remove unused class SingleMessageResultIterator
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 4db213893c700c64d66bebb2c7137e4918b0003b
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Mon Mar 4 12:08:14 2024 +0100
[IMPROVE] Remove unused class SingleMessageResultIterator
---
.../processor/base/MailboxEventAnalyserTest.java | 34 ----------------------
1 file changed, 34 deletions(-)
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
index 06ae218023..2993e147cc 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
@@ -31,14 +31,12 @@ import java.util.Optional;
import jakarta.mail.Flags;
-import org.apache.commons.lang3.NotImplementedException;
import org.apache.james.core.Username;
import org.apache.james.events.Event;
import org.apache.james.events.EventBusTestFixture;
import org.apache.james.events.InVMEventBus;
import org.apache.james.events.MemoryEventDeadLetters;
import org.apache.james.events.delivery.InVmEventDelivery;
-import org.apache.james.imap.encode.FakeImapSession;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MailboxSessionUtil;
@@ -55,7 +53,6 @@ import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageMetaData;
import org.apache.james.mailbox.model.MessageResult;
-import org.apache.james.mailbox.model.MessageResultIterator;
import org.apache.james.mailbox.model.TestId;
import org.apache.james.mailbox.model.ThreadId;
import org.apache.james.mailbox.model.UidValidity;
@@ -90,37 +87,6 @@ class MailboxEventAnalyserTest {
.newFlags(new Flags())
.build();
- public static class SingleMessageResultIterator implements MessageResultIterator {
- private final MessageResult messageResult;
- private boolean done;
-
- public SingleMessageResultIterator(MessageResult messageResult) {
- this.messageResult = messageResult;
- done = false;
- }
-
- @Override
- public void remove() {
- throw new NotImplementedException("Not implemented");
- }
-
- @Override
- public MessageResult next() {
- done = true;
- return messageResult;
- }
-
- @Override
- public boolean hasNext() {
- return !done;
- }
-
- @Override
- public MailboxException getException() {
- throw new NotImplementedException("Not implemented");
- }
- }
-
private static final MessageUid MESSAGE_UID = MessageUid.of(1);
private static final Username USER = Username.of("user");
private static final MailboxSession MAILBOX_SESSION = MailboxSessionUtil.create(USER);
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
(james-project) 09/09: [FIX] SelectedMailboxImpl: using Mono defer to avoid eager invoke idleEventListener
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 5c40b2dd7258dbf3dc74a9e4c6b8c5f8e7d15078
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Mon Mar 4 14:28:37 2024 +0100
[FIX] SelectedMailboxImpl: using Mono defer to avoid eager invoke idleEventListener
---
.../org/apache/james/imap/processor/base/SelectedMailboxImpl.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
index ce035a2a76..95af2d2ac2 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
@@ -385,9 +385,8 @@ public class SelectedMailboxImpl implements SelectedMailbox, EventListener.React
public Publisher<Void> reactiveEvent(Event event) {
return Mono.fromRunnable(() -> synchronizedEvent(event))
.subscribeOn(Schedulers.boundedElastic())
- .then(Optional.ofNullable(idleEventListener.get())
- .map(listener -> Mono.from(listener.reactiveEvent(event)))
- .orElse(Mono.empty()));
+ .then(Mono.fromCallable(idleEventListener::get)
+ .flatMap(listener -> Mono.from(listener.reactiveEvent(event))));
}
private synchronized void synchronizedEvent(Event event) {
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
(james-project) 01/09: [IMPROVE] SelectedMailboxImpl: extract isFromOtherSession
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 c274b412e180aaae53c3bd6371d68555c926ad7b
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Mon Mar 4 07:54:06 2024 +0100
[IMPROVE] SelectedMailboxImpl: extract isFromOtherSession
---
.../apache/james/imap/processor/base/SelectedMailboxImpl.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
index 00e0dca78b..6d05fb76aa 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
@@ -127,7 +127,6 @@ public class SelectedMailboxImpl implements SelectedMailbox, EventListener.React
private final MailboxId mailboxId;
private final EventBus eventBus;
private final ImapSession session;
- private final MailboxSession.SessionId sessionId;
private final MailboxSession mailboxSession;
private final UidMsnConverter uidMsnConverter;
private final Set<MessageUid> recentUids = new TreeSet<>();
@@ -144,7 +143,6 @@ public class SelectedMailboxImpl implements SelectedMailbox, EventListener.React
public SelectedMailboxImpl(MailboxManager mailboxManager, EventBus eventBus, ImapSession session, MessageManager messageManager) {
this.eventBus = eventBus;
this.session = session;
- this.sessionId = session.getMailboxSession().getSessionId();
this.mailboxManager = mailboxManager;
this.messageManager = messageManager;
this.mailboxSession = session.getMailboxSession();
@@ -432,12 +430,16 @@ public class SelectedMailboxImpl implements SelectedMailbox, EventListener.React
}
private Void handleMailboxDeletion(MailboxDeletion mailboxDeletion) {
- if (mailboxDeletion.getSessionId() != sessionId) {
+ if (isFromOtherSession(mailboxDeletion)) {
isDeletedByOtherSession.set(true);
}
return VOID;
}
+ private boolean isFromOtherSession(MailboxEvent mailboxDeletion) {
+ return mailboxDeletion.getSessionId() != mailboxSession.getSessionId();
+ }
+
private Void handleMailboxExpunge(MessageEvent messageEvent) {
expungedUids.addAll(messageEvent.getUids());
return VOID;
@@ -445,7 +447,7 @@ public class SelectedMailboxImpl implements SelectedMailbox, EventListener.React
private Void handleFlagsUpdates(FlagsUpdated updated) {
List<UpdatedFlags> uFlags = updated.getUpdatedFlags();
- if (sessionId != updated.getSessionId() || !silentFlagChanges.get()) {
+ if (isFromOtherSession(updated) || !silentFlagChanges.get()) {
for (UpdatedFlags u : uFlags) {
if (interestingFlags(u)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
(james-project) 03/09: [IMPROVE] SelectedMailboxImpl: remove unused method
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 10b6197c072eab7ec3cc09e37f1b7faa7cb36b44
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Mon Mar 4 07:54:35 2024 +0100
[IMPROVE] SelectedMailboxImpl: remove unused method
---
.../james/imap/processor/base/SelectedMailboxImpl.java | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
index 974627ba69..4449027383 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
@@ -306,24 +306,12 @@ public class SelectedMailboxImpl implements SelectedMailbox, EventListener.React
}
return result;
}
-
-
@Override
public synchronized void resetExpungedUids() {
expungedUids.clear();
}
- /**
- * Are flag changes from current session ignored?
- *
- * @return true if any flag changes from current session will be ignored,
- * false otherwise
- */
- public final boolean isSilentFlagChanges() {
- return silentFlagChanges.get();
- }
-
/**
* Sets whether changes from current session should be ignored.
*
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org