atiaomar1978-hub opened a new pull request, #25523: URL: https://github.com/apache/camel/pull/25523
_AI-generated PR on behalf of atiaomar1978-hub_ ## Summary Fixes a Camel 4.x regression where `DefaultAttachmentMessage.hasAttachments()` returns `true` after read-only attachment inspection (e.g. `getAttachments()`, `getAttachmentNames()`) even when no attachments were added. This caused `MimeMultipartDataFormat.marshal()` to incorrectly take the multipart code path for plain XML/text messages, corrupting the message body. ## Root cause The MessageTrait refactor eagerly registers the `ATTACHMENTS` trait with an empty `LinkedHashMap` in `getAttachmentsMap()`. `hasAttachments()` only checked trait presence, not map emptiness — unlike Camel 3.x which checked `map != null && !map.isEmpty()`. ## Fix `hasAttachments()` now verifies the trait map exists **and** is non-empty, without calling `getAttachmentsMap()` (avoids lazy-init on the check itself). ## Tests Added `DefaultAttachmentMessageHasAttachmentsTest` with 10 regression tests covering read-only inspection, converter flow, add/remove/clear lifecycle, and HTTP binding simulation. All existing `camel-attachments` tests pass. ## Reviews - **Bugbot**: No bugs found - **Grok review**: Minimal correct fix restoring Camel 3.14.7 semantics; recommend backport to `camel-4.14.x` ## Backport Follow-up PR to `camel-4.14.x` planned. Fixes: https://issues.apache.org/jira/browse/CAMEL-24398 -- 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]
