You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/01/17 11:01:44 UTC

[5/8] james-project git commit: MAILBOX-372 Allow MailboxListeners to throw exception

MAILBOX-372 Allow MailboxListeners to throw exception


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

Branch: refs/heads/master
Commit: 5c301e8e3d37726d16ac765f5a5c2e8ea215d083
Parents: 21cde6d
Author: Benoit Tellier <bt...@linagora.com>
Authored: Wed Jan 16 11:41:52 2019 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Thu Jan 17 18:01:13 2019 +0700

----------------------------------------------------------------------
 .../apache/james/mailbox/MailboxListener.java   |  2 +-
 .../james/mailbox/events/GroupContract.java     | 22 ++++++------
 .../james/mailbox/events/KeyContract.java       | 38 ++++++++++----------
 .../events/delivery/InVmEventDelivery.java      |  2 ++
 .../events/delivery/InVmEventDeliveryTest.java  | 18 +++++-----
 .../james/mailbox/events/GroupRegistration.java |  3 +-
 .../mailbox/events/KeyRegistrationHandler.java  |  3 +-
 .../processor/base/SelectedMailboxImplTest.java |  2 +-
 8 files changed, 47 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/5c301e8e/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
index d845154..98607f1 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
@@ -67,7 +67,7 @@ public interface MailboxListener {
      *
      * @param event not null
      */
-    void event(Event event);
+    void event(Event event) throws Exception;
 
     interface QuotaEvent extends Event {
         QuotaRoot getQuotaRoot();

http://git-wip-us.apache.org/repos/asf/james-project/blob/5c301e8e/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java
index beeeb0b..870f75f 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java
@@ -55,7 +55,7 @@ public interface GroupContract {
     interface SingleEventBusGroupContract extends EventBusContract {
 
         @Test
-        default void listenerGroupShouldReceiveEvents() {
+        default void listenerGroupShouldReceiveEvents() throws Exception {
             MailboxListener listener = newListener();
 
             eventBus().register(listener, GROUP_A);
@@ -66,7 +66,7 @@ public interface GroupContract {
         }
 
         @Test
-        default void groupListenersShouldNotReceiveNoopEvents() {
+        default void groupListenersShouldNotReceiveNoopEvents() throws Exception {
             MailboxListener listener = newListener();
 
             eventBus().register(listener, GROUP_A);
@@ -79,7 +79,7 @@ public interface GroupContract {
         }
 
         @Test
-        default void dispatchShouldNotThrowWhenAGroupListenerFails() {
+        default void dispatchShouldNotThrowWhenAGroupListenerFails() throws Exception {
             MailboxListener listener = newListener();
             doThrow(new RuntimeException()).when(listener).event(any());
 
@@ -90,7 +90,7 @@ public interface GroupContract {
         }
 
         @Test
-        default void eachListenerGroupShouldReceiveEvents() {
+        default void eachListenerGroupShouldReceiveEvents() throws Exception {
             MailboxListener listener = newListener();
             MailboxListener listener2 = newListener();
             eventBus().register(listener, GROUP_A);
@@ -103,7 +103,7 @@ public interface GroupContract {
         }
 
         @Test
-        default void unregisteredGroupListenerShouldNotReceiveEvents() {
+        default void unregisteredGroupListenerShouldNotReceiveEvents() throws Exception {
             MailboxListener listener = newListener();
             Registration registration = eventBus().register(listener, GROUP_A);
 
@@ -148,7 +148,7 @@ public interface GroupContract {
         }
 
         @Test
-        default void registerShouldAcceptAlreadyUnregisteredGroups() {
+        default void registerShouldAcceptAlreadyUnregisteredGroups() throws Exception {
             MailboxListener listener = newListener();
 
             eventBus().register(listener, GROUP_A).unregister();
@@ -160,7 +160,7 @@ public interface GroupContract {
         }
 
         @Test
-        default void dispatchShouldCallSynchronousListener() {
+        default void dispatchShouldCallSynchronousListener() throws Exception {
             MailboxListener listener = newListener();
 
             eventBus().register(listener, GROUP_A);
@@ -183,7 +183,7 @@ public interface GroupContract {
         }
 
         @Test
-        default void allGroupListenersShouldBeExecutedWhenAGroupListenerFails() {
+        default void allGroupListenersShouldBeExecutedWhenAGroupListenerFails() throws Exception {
             MailboxListener listener = newListener();
 
             MailboxListener failingListener = mock(MailboxListener.class);
@@ -202,7 +202,7 @@ public interface GroupContract {
     interface MultipleEventBusGroupContract extends EventBusContract.MultipleEventBusContract {
 
         @Test
-        default void groupsDefinedOnlyOnSomeNodesShouldBeNotified() {
+        default void groupsDefinedOnlyOnSomeNodesShouldBeNotified() throws Exception {
             MailboxListener mailboxListener = newListener();
 
             eventBus().register(mailboxListener, GROUP_A);
@@ -213,7 +213,7 @@ public interface GroupContract {
         }
 
         @Test
-        default void groupListenersShouldBeExecutedOnceInAControlledEnvironment() {
+        default void groupListenersShouldBeExecutedOnceInAControlledEnvironment() throws Exception {
             MailboxListener mailboxListener = newListener();
 
             eventBus().register(mailboxListener, GROUP_A);
@@ -225,7 +225,7 @@ public interface GroupContract {
         }
 
         @Test
-        default void unregisterShouldStopNotificationForDistantGroups() {
+        default void unregisterShouldStopNotificationForDistantGroups() throws Exception {
             MailboxListener mailboxListener = newListener();
 
             eventBus().register(mailboxListener, GROUP_A).unregister();

http://git-wip-us.apache.org/repos/asf/james-project/blob/5c301e8e/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java
index 1421174..6e82af0 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java
@@ -58,7 +58,7 @@ public interface KeyContract extends EventBusContract {
 
     interface SingleEventBusKeyContract extends EventBusContract {
         @Test
-        default void registeredListenersShouldNotReceiveNoopEvents() {
+        default void registeredListenersShouldNotReceiveNoopEvents() throws Exception {
             MailboxListener listener = newListener();
 
             eventBus().register(listener, KEY_1);
@@ -71,7 +71,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void dispatchShouldNotThrowWhenARegisteredListenerFails() {
+        default void dispatchShouldNotThrowWhenARegisteredListenerFails() throws Exception {
             MailboxListener listener = newListener();
             doThrow(new RuntimeException()).when(listener).event(any());
 
@@ -82,7 +82,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void dispatchShouldNotNotifyRegisteredListenerWhenEmptyKeySet() {
+        default void dispatchShouldNotNotifyRegisteredListenerWhenEmptyKeySet() throws Exception {
             MailboxListener listener = newListener();
             eventBus().register(listener, KEY_1);
 
@@ -93,7 +93,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void dispatchShouldNotNotifyListenerRegisteredOnOtherKeys() {
+        default void dispatchShouldNotNotifyListenerRegisteredOnOtherKeys() throws Exception {
             MailboxListener listener = newListener();
             eventBus().register(listener, KEY_1);
 
@@ -104,7 +104,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void dispatchShouldNotifyRegisteredListeners() {
+        default void dispatchShouldNotifyRegisteredListeners() throws Exception {
             MailboxListener listener = newListener();
             eventBus().register(listener, KEY_1);
 
@@ -114,7 +114,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void dispatchShouldNotifyOnlyRegisteredListener() {
+        default void dispatchShouldNotifyOnlyRegisteredListener() throws Exception {
             MailboxListener listener = newListener();
             MailboxListener listener2 = newListener();
             eventBus().register(listener, KEY_1);
@@ -128,7 +128,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void dispatchShouldNotifyAllListenersRegisteredOnAKey() {
+        default void dispatchShouldNotifyAllListenersRegisteredOnAKey() throws Exception {
             MailboxListener listener = newListener();
             MailboxListener listener2 = newListener();
             eventBus().register(listener, KEY_1);
@@ -141,7 +141,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void registerShouldAllowDuplicatedRegistration() {
+        default void registerShouldAllowDuplicatedRegistration() throws Exception {
             MailboxListener listener = newListener();
             eventBus().register(listener, KEY_1);
             eventBus().register(listener, KEY_1);
@@ -152,7 +152,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void unregisterShouldRemoveDoubleRegisteredListener() {
+        default void unregisterShouldRemoveDoubleRegisteredListener() throws Exception {
             MailboxListener listener = newListener();
             eventBus().register(listener, KEY_1);
             eventBus().register(listener, KEY_1).unregister();
@@ -164,7 +164,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void callingAllUnregisterMethodShouldUnregisterTheListener() {
+        default void callingAllUnregisterMethodShouldUnregisterTheListener() throws Exception {
             MailboxListener listener = newListener();
             Registration registration = eventBus().register(listener, KEY_1);
             eventBus().register(listener, KEY_1).unregister();
@@ -177,7 +177,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void unregisterShouldHaveNotNotifyWhenCalledOnDifferentKeys() {
+        default void unregisterShouldHaveNotNotifyWhenCalledOnDifferentKeys() throws Exception {
             MailboxListener listener = newListener();
             eventBus().register(listener, KEY_1);
             eventBus().register(listener, KEY_2).unregister();
@@ -199,7 +199,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void dispatchShouldAcceptSeveralKeys() {
+        default void dispatchShouldAcceptSeveralKeys() throws Exception {
             MailboxListener listener = newListener();
             eventBus().register(listener, KEY_1);
 
@@ -209,7 +209,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void dispatchShouldCallListenerOnceWhenSeveralKeysMatching() {
+        default void dispatchShouldCallListenerOnceWhenSeveralKeysMatching() throws Exception {
             MailboxListener listener = newListener();
             eventBus().register(listener, KEY_1);
             eventBus().register(listener, KEY_2);
@@ -220,7 +220,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void dispatchShouldNotNotifyUnregisteredListener() {
+        default void dispatchShouldNotNotifyUnregisteredListener() throws Exception {
             MailboxListener listener = newListener();
             eventBus().register(listener, KEY_1).unregister();
 
@@ -231,7 +231,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void dispatchShouldNotBlockAsynchronousListener() {
+        default void dispatchShouldNotBlockAsynchronousListener() throws Exception {
             MailboxListener listener = newListener();
             when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS);
             CountDownLatch latch = new CountDownLatch(1);
@@ -266,7 +266,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void allRegisteredListenersShouldBeExecutedWhenARegisteredListenerFails() {
+        default void allRegisteredListenersShouldBeExecutedWhenARegisteredListenerFails() throws Exception {
             MailboxListener listener = newListener();
 
             MailboxListener failingListener = mock(MailboxListener.class);
@@ -285,7 +285,7 @@ public interface KeyContract extends EventBusContract {
     interface MultipleEventBusKeyContract extends MultipleEventBusContract {
 
         @Test
-        default void crossEventBusRegistrationShouldBeAllowed() {
+        default void crossEventBusRegistrationShouldBeAllowed() throws Exception {
             MailboxListener mailboxListener = newListener();
 
             eventBus().register(mailboxListener, KEY_1);
@@ -296,7 +296,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void unregisteredDistantListenersShouldNotBeNotified() {
+        default void unregisteredDistantListenersShouldNotBeNotified() throws Exception {
             MailboxListener mailboxListener = newListener();
 
             eventBus().register(mailboxListener, KEY_1).unregister();
@@ -308,7 +308,7 @@ public interface KeyContract extends EventBusContract {
         }
 
         @Test
-        default void allRegisteredListenersShouldBeDispatched() {
+        default void allRegisteredListenersShouldBeDispatched() throws Exception {
             MailboxListener mailboxListener1 = newListener();
             MailboxListener mailboxListener2 = newListener();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/5c301e8e/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java
index c59a8b8..c5446dd 100644
--- a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java
+++ b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java
@@ -95,6 +95,8 @@ public class InVmEventDelivery implements EventDelivery {
         TimeMetric timer = metricFactory.timer("mailbox-listener-" + mailboxListener.getClass().getSimpleName());
         try {
             mailboxListener.event(event);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
         } finally {
             timer.stopAndPublish();
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/5c301e8e/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/InVmEventDeliveryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/InVmEventDeliveryTest.java b/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/InVmEventDeliveryTest.java
index 9796328..207d319 100644
--- a/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/InVmEventDeliveryTest.java
+++ b/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/InVmEventDeliveryTest.java
@@ -175,7 +175,7 @@ class InVmEventDeliveryTest {
     }
 
     @Test
-    void deliverShouldHaveCalledSynchronousListenersWhenAllListenerExecutedJoined() {
+    void deliverShouldHaveCalledSynchronousListenersWhenAllListenerExecutedJoined() throws Exception {
         when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.SYNCHRONOUS);
 
         inVmEventDelivery.deliver(ImmutableList.of(listener), event).allListenerFuture().block();
@@ -184,7 +184,7 @@ class InVmEventDeliveryTest {
     }
 
     @Test
-    void deliverShouldHaveCalledAsynchronousListenersWhenAllListenerExecutedJoined() {
+    void deliverShouldHaveCalledAsynchronousListenersWhenAllListenerExecutedJoined() throws Exception {
         when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS);
 
         inVmEventDelivery.deliver(ImmutableList.of(listener), event).allListenerFuture().block();
@@ -193,7 +193,7 @@ class InVmEventDeliveryTest {
     }
 
     @Test
-    void deliverShouldHaveCalledSynchronousListenersWhenSynchronousListenerExecutedJoined() {
+    void deliverShouldHaveCalledSynchronousListenersWhenSynchronousListenerExecutedJoined() throws Exception {
         when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.SYNCHRONOUS);
 
         inVmEventDelivery.deliver(ImmutableList.of(listener), event).synchronousListenerFuture().block();
@@ -202,7 +202,7 @@ class InVmEventDeliveryTest {
     }
 
     @Test
-    void deliverShouldNotBlockOnAsynchronousListenersWhenSynchronousListenerExecutedJoined() {
+    void deliverShouldNotBlockOnAsynchronousListenersWhenSynchronousListenerExecutedJoined() throws Exception {
         when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS);
         CountDownLatch latch = new CountDownLatch(1);
         doAnswer(invocation -> {
@@ -218,7 +218,7 @@ class InVmEventDeliveryTest {
     }
 
     @Test
-    void deliverShouldNotBlockOnSynchronousListenersWhenNoJoin() {
+    void deliverShouldNotBlockOnSynchronousListenersWhenNoJoin() throws Exception {
         when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.SYNCHRONOUS);
         CountDownLatch latch = new CountDownLatch(1);
         doAnswer(invocation -> {
@@ -234,7 +234,7 @@ class InVmEventDeliveryTest {
     }
 
     @Test
-    void deliverShouldNotBlockOnAsynchronousListenersWhenNoJoin() {
+    void deliverShouldNotBlockOnAsynchronousListenersWhenNoJoin() throws Exception {
         when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS);
         CountDownLatch latch = new CountDownLatch(1);
         doAnswer(invocation -> {
@@ -250,7 +250,7 @@ class InVmEventDeliveryTest {
     }
 
     @Test
-    void deliverShouldEventuallyDeliverAsynchronousListenersWhenSynchronousListenerExecutedJoined() {
+    void deliverShouldEventuallyDeliverAsynchronousListenersWhenSynchronousListenerExecutedJoined() throws Exception {
         when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS);
 
         inVmEventDelivery.deliver(ImmutableList.of(listener), event).synchronousListenerFuture().block();
@@ -259,7 +259,7 @@ class InVmEventDeliveryTest {
     }
 
     @Test
-    void deliverShouldEventuallyDeliverSynchronousListenersWhenNoJoin() {
+    void deliverShouldEventuallyDeliverSynchronousListenersWhenNoJoin() throws Exception {
         when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.SYNCHRONOUS);
 
         inVmEventDelivery.deliver(ImmutableList.of(listener), event);
@@ -268,7 +268,7 @@ class InVmEventDeliveryTest {
     }
 
     @Test
-    void deliverShouldCallSynchronousListenersWhenAsynchronousListenersAreAlsoRegistered() {
+    void deliverShouldCallSynchronousListenersWhenAsynchronousListenersAreAlsoRegistered() throws Exception {
         when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS);
         when(listener2.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.SYNCHRONOUS);
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/5c301e8e/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java
index b382dee..68f67be 100644
--- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java
+++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java
@@ -35,6 +35,7 @@ import org.apache.james.event.json.EventSerializer;
 import org.apache.james.mailbox.Event;
 import org.apache.james.mailbox.MailboxListener;
 
+import com.github.fge.lambdas.Throwing;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
@@ -149,7 +150,7 @@ class GroupRegistration implements Registration {
         int currentRetryCount = getRetryCount(acknowledgableDelivery);
 
         return delayGenerator.delayIfHaveTo(currentRetryCount)
-            .flatMap(any -> Mono.fromRunnable(() -> mailboxListener.event(event)))
+            .flatMap(any -> Mono.fromRunnable(Throwing.runnable(() -> mailboxListener.event(event))))
             .onErrorResume(throwable -> retryHandler.handleRetry(eventAsBytes, event, currentRetryCount, throwable))
             .then(Mono.fromRunnable(acknowledgableDelivery::ack))
             .subscribeWith(MonoProcessor.create())

http://git-wip-us.apache.org/repos/asf/james-project/blob/5c301e8e/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/KeyRegistrationHandler.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/KeyRegistrationHandler.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/KeyRegistrationHandler.java
index ff388df..3610b4b 100644
--- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/KeyRegistrationHandler.java
+++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/KeyRegistrationHandler.java
@@ -33,6 +33,7 @@ import org.apache.james.mailbox.MailboxListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.github.fge.lambdas.Throwing;
 import com.rabbitmq.client.AMQP;
 import com.rabbitmq.client.Connection;
 import com.rabbitmq.client.Delivery;
@@ -111,7 +112,7 @@ public class KeyRegistrationHandler {
         Event event = toEvent(delivery);
 
         return mailboxListenerRegistry.getLocalMailboxListeners(registrationKey)
-            .flatMap(listener -> Mono.fromRunnable(() -> listener.event(event))
+            .flatMap(listener -> Mono.fromRunnable(Throwing.runnable(() -> listener.event(event)))
                 .doOnError(e -> LOGGER.error("Exception happens when handling event of user {}", event.getUser().asString(), e))
                 .onErrorResume(e -> Mono.empty()))
             .subscribeOn(Schedulers.elastic())

http://git-wip-us.apache.org/repos/asf/james-project/blob/5c301e8e/protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java
----------------------------------------------------------------------
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 a307c27..d89a36b 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
@@ -169,7 +169,7 @@ public class SelectedMailboxImplTest {
         };
     }
 
-    private void emitEvent(MailboxListener mailboxListener) {
+    private void emitEvent(MailboxListener mailboxListener) throws Exception {
         mailboxListener.event(EventFactory.added()
             .randomEventId()
             .mailboxSession(MailboxSessionUtil.create("user"))


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