spring-projects / spring-integration

Spring Integration provides an extension of the Spring programming model to support the well-known Enterprise Integration Patterns (EIP)
http://projects.spring.io/spring-integration/
Apache License 2.0
1.55k stars 1.11k forks source link

AbstractMailReceiver.receive returns MimeMessage with outdated flags #9633

Closed artembilan closed 2 weeks ago

artembilan commented 2 weeks ago

Discussed in https://github.com/spring-projects/spring-integration/discussions/9632

Originally posted by **dru1** November 6, 2024 Hi, it looks like after merging [PR#9546](https://github.com/spring-projects/spring-integration/pull/9546) the returned values from `AbstractMailReceiver#receive` no longer reflect the current state of the `MimeMessage` **after** the receiving process. The message flags of the received messages are outdated and don't contain the changes of `AbstractMailReceiver#setMessageFlags`, because the flags are only applied to the original message and not the copy (`AbstractMailReceiver.IntegrationMimeMessage`). The behavior change can be verified by debugging the returned values from `receiver.receive()` in the [new unit test method](https://github.com/spring-projects/spring-integration/blob/846d655084e2a7a60e9646a665022b351c0152cc/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java#L1008). The flags are empty in the debugger, while the original messages (`msg1`, `msg2`) contain the flags `\Seen` and `spring-integration-mail-adapter`. Was this change in behavior intentional? This looks like a bug to me, because message processing after the initial receiving step now works with an outdated state. Best regards, Daniel