Skip to content

Improve ImapIdleChannelAdapter #3045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 28, 2019

Conversation

artembilan
Copy link
Member

  • 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

* 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
@artembilan
Copy link
Member Author

Also it looks like IdleTask class (and its instace) is really redundant and could be present as a method...

Copy link
Contributor

@garyrussell garyrussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one point.

@@ -156,29 +156,22 @@ public void setApplicationEventPublisher(ApplicationEventPublisher applicationEv
protected void doStart() {
TaskScheduler scheduler = getTaskScheduler();
Assert.notNull(scheduler, "'taskScheduler' must not be null");
if (this.sendingTaskExecutor == null) {
this.sendingTaskExecutor = Executors.newFixedThreadPool(1);
}
this.receivingTask = scheduler.schedule(new ReceivingTask(), this.receivingTaskTrigger);
}

@Override
// guarded by super#lifecycleLock
protected void doStop() {
this.receivingTask.cancel(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we still need to cancel the pingTask in the receiver. Add Lifecycle ?

What about closing the folder?

* Also close folder for each `stop()`, as well as in the `destroy()`
@garyrussell garyrussell merged commit 6d0757a into spring-projects:master Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants