oscerd opened a new pull request, #26659: URL: https://github.com/apache/camel/pull/26659
This fixes [CAMEL-24432](https://issues.apache.org/jira/browse/CAMEL-24432). Three independent paths turned one hostile or merely unusual message into a consumer that never made progress again — it repeated on every poll until the message was removed out of band: 1. **`MailSorter.compareMessageProperty`** dereferenced values that are optional in RFC 5322 or may be absent on the server (`getSubject()`, the sent/received dates, `getFrom()`/`getRecipients()` before `[0]`), so it threw from inside `Arrays.sort` and aborted the whole poll. Client-side sorting is always used for POP3, and for IMAP when the server has no SORT capability. Comparisons now go through a `compareNullable` helper (missing value ordered first) and address arrays through a `firstAddress` helper that returns null when there is no entry. 2. **`MailBinding.extractAttachmentsFromMultipart`** recursed on nested multiparts with no depth limit, so a deeply nested message raised `StackOverflowError`. Recursion is now bounded at `MAX_MULTIPART_DEPTH`; the protected two-arg method stays as the entry point and delegates to a private depth-carrying overload, so the subclass extension point is unchanged. 3. **`MailConverters.toString(Message)`** looped while the content was a `MimeMultipart` but only reassigned it when `getCount() > 0`, so an empty multipart (reachable where `mail.mime.multipart.allowempty` is set) spun forever and pinned the thread. It now returns null. All three are covered by `MailPoisonMessageTest`, and each fails against the previous code: a `NullPointerException` from `compareTo`, a `StackOverflowError`, and a 5-second timeout respectively. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
