Close mail folder if no messages to produce

Related to https://stackoverflow.com/questions/71667731/spring-integration-mimemessage-gmail-folder-is-not-open-exception

If no mail messages pulled from the folder or all of them are filtered out,
there is nothing to produce downstream.
Therefore, always close the folder in the end of `AbstractMailReceiver.receive()`
when no messages and even if `autoCloseFolder == false`

**Cherry-pick to `5.5.x`**
This commit is contained in:
Artem Bilan
2022-04-07 12:09:39 -04:00
committed by Gary Russell
parent f013aa8c29
commit 802d217a9a
3 changed files with 21 additions and 7 deletions

View File

@@ -140,6 +140,9 @@ This functionality is enabled with this combination of options: no `headerMapper
The `MimeMessage` is present as the payload of the Spring message produced.
In this case, the only header populated is the mentioned above `IntegrationMessageHeaderAccessor.CLOSEABLE_RESOURCE` for the folder which must be closed when processing of the `MimeMessage` is complete.
Starting with version 5.5.11, the folder is closed automatically after `AbstractMailReceiver.receive()` if no messages received or all of them are filtered out independently of the `autoCloseFolder` flag.
In this case there is nothing to produce downstream for possible logic around `IntegrationMessageHeaderAccessor.CLOSEABLE_RESOURCE` header.
[[mail-mapping]]
=== Inbound Mail Message Mapping