Skip to content

GH-8577: Revise ImapIdleChannelAdapter logic #8588

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 3 commits into from
Mar 29, 2023

Conversation

artembilan
Copy link
Member

Fixes #8577

When we process mail messages in async manner, it is possible that we end up in a race condition situation where the next idle cycle closes the folder.

It is possible to reopen the folder, but feels better to block the current idle cycle until we are done with the message and therefore keep folder opened.

  • Deprecate ImapIdleChannelAdapter.sendingTaskExecutor in favor of an ExecutorChannel as an output for this channel adapter or similar async hand-off downstream.
  • Make use of shouldReconnectAutomatically as it is advertised for this channel adapter
  • Optimize the proxy creation for message sending task

Fixes spring-projects#8577

When we process mail messages in async manner, it is possible that we end up
in a race condition situation where the next idle cycle closes the folder.

It is possible to reopen the folder, but feels better to block the current idle
cycle until we are done with the message and therefore keep folder opened.

* Deprecate `ImapIdleChannelAdapter.sendingTaskExecutor` in favor of an `ExecutorChannel`
as an output for this channel adapter or similar async hand-off downstream.
* Make use of `shouldReconnectAutomatically` as it is advertised for this channel adapter
* Optimize the proxy creation for message sending task
*/
@Deprecated(since = "6.1", forRemoval = true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we need to deprecate in 6.0 and just remove here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd love to, but that is a behavior change and making it deprecated there would just lead to always use a default one.
There is a simple workaround with setting a SyncTaskExecutor instead.
Plus it is not too far from 6.2 this Fall where we indeed will remove it already.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just bite the bullet and make it a breaking change. Deprecating implies that it will still work, but we don't encourage the use.

@@ -167,10 +167,11 @@
<xsd:attribute name="task-executor" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
Reference to a bean that implements
[DEPRECATED] Reference to a bean that implements
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment re: deprecation; I don't see how we can deprecate it, but just ignore it.

Copy link
Member Author

Choose a reason for hiding this comment

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

We do ignore it from the parser.

Copy link
Contributor

Choose a reason for hiding this comment

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

I saw that; but it makes no sense to me; if the parser ignores it, we should remove it altogether (and record it as a breaking change in the migration guide).

Copy link
Member Author

Choose a reason for hiding this comment

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

OK. Let me issue an new PR against 6.0.x to just deprecate this executor.
Then I'll fix this as a removal.
And yes: in the end a dedicated migration guide note.

Comment on lines 146 to 148
Starting with version 6.1, the `ImapIdleChannelAdapter` doesn't do an asynchronous message publishing anymore and respective `sendingTaskExecutor` option is deprecated for removal in the next version.
This is necessary to block the idle listener loop for messages processing downstream (e.g. with big attachments) for which the mail folder must remain opened.
If an async hand-off is appropriate, an `ExecutorChannel` as an output channel for this adapter is a recommended way from now on.
Copy link
Contributor

Choose a reason for hiding this comment

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

This will need to be changed if you agree on the deprecation issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I do not. We will change this sentence in 6.2 respectively.

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.

Doc polishing.

Co-authored-by: Gary Russell <[email protected]>
@artembilan artembilan requested a review from garyrussell March 29, 2023 14:05
@garyrussell garyrussell merged commit 4fdbdf1 into spring-projects:main Mar 29, 2023
@artembilan artembilan deleted the GH-8577 branch March 29, 2023 16:19
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.

FolderClosedException when downloading large file attachments
2 participants