Skip to content

Commit

Permalink
GH-9633: MailReceiver: also set flags into IntegrationMimeMessage
Browse files Browse the repository at this point in the history
Fixes: #9633
Issue link: #9633

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`).

* Call `setMessageFlagsAndMaybeDeleteMessages()` for `IntegrationMimeMessage` copies as well

(cherry picked from commit 1d85d6b)
  • Loading branch information
artembilan authored and spring-builds committed Nov 6, 2024
1 parent aeeca93 commit ef8ad13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ private void postProcessFilteredMessages(Message[] filteredMessages) throws Mess
}

setMessageFlagsAndMaybeDeleteMessages(messages);
if (filteredMessages.length > 0 && filteredMessages[0] instanceof IntegrationMimeMessage) {
setMessageFlagsAndMaybeDeleteMessages(filteredMessages);
}
}

private void setMessageFlagsAndMaybeDeleteMessages(Message[] messages) throws MessagingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ public void receiveMarkAsReadAndDelete() throws Exception {
assertThat(msg1.getFlags().contains(Flag.SEEN)).isTrue();
assertThat(msg2.getFlags().contains(Flag.SEEN)).isTrue();

verify(receiver, times(1)).deleteMessages(Mockito.any());
verify(receiver, times(2)).deleteMessages(Mockito.any());
}

@Test
Expand Down

0 comments on commit ef8ad13

Please sign in to comment.