Order of attachments is lost when converting a MimeMessage to an Email
timestudybuddy opened this issue · 4 comments
I'm writing a script that monitors an IMAP box, and clones bounce messages, adjusting the recipients so that they reach our customers' corresponding Administrators. I'm using simple-java-mail to convert an IMAPMessage/MimeMessage into an Email, which we can then feed into our existing mail subsystem. I've noticed that the order of attachments gets lost during this conversion. Bounce messages follow a specific standard, and the order of these attachments matters.
I traced it down to org.simplejavamail.converter.internal.mimemessage.ParsedMimeMessageComponents.attachmentList being a SortedSet. This effectively orders the attachments by their name. Is there a reason this isn't simply an ArrayList?
Hmm, I'm not sure, but the decision was made in the early days of this project, presumably due to testing challenges where the attachments were out of order otherwise. However, I replaced it LinkedHashSet and everything tested fine still. Would that would for you?