Improve ImapIdleChannelAdapter (#3045)
* Improve ImapIdleChannelAdapter * We should not destroy a `TaskExecutor` in the `stop()`, especially when we are going to restart eventually. Move that logic into `destroy()` * we should not destroy `MailReceiver` in the `stop()`; we don't reinstate it in the `start()`. Move the logic into `destroy()` * Wrap `ReceivingTask` and `IdleTask` into `isRunning()` condition to avoid task executions when we are in stopped state * Remove `ImapMailReceiverTests.testExecShutdown()` since it is not relevant any more and doesn't reflect `mail` module requirements * * Add `ImapMailReceiver.cancelPing()` hook * Also close folder for each `stop()`, as well as in the `destroy()`
This commit is contained in:
committed by
Gary Russell
parent
4db71d751a
commit
6d0757a08a
@@ -34,7 +34,6 @@ import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -808,25 +807,6 @@ public class ImapMailReceiverTests {
|
||||
return folder;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecShutdown() {
|
||||
ImapIdleChannelAdapter adapter = new ImapIdleChannelAdapter(new ImapMailReceiver());
|
||||
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
|
||||
taskScheduler.initialize();
|
||||
adapter.setTaskScheduler(taskScheduler);
|
||||
adapter.setReconnectDelay(1);
|
||||
adapter.start();
|
||||
ExecutorService exec = TestUtils.getPropertyValue(adapter, "sendingTaskExecutor", ExecutorService.class);
|
||||
adapter.stop();
|
||||
assertThat(exec.isShutdown()).isTrue();
|
||||
adapter.start();
|
||||
exec = TestUtils.getPropertyValue(adapter, "sendingTaskExecutor", ExecutorService.class);
|
||||
adapter.stop();
|
||||
assertThat(exec.isShutdown()).isTrue();
|
||||
|
||||
taskScheduler.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullMessages() throws Exception {
|
||||
Message message1 = mock(Message.class);
|
||||
|
||||
Reference in New Issue
Block a user