You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "atiaomar1978-hub (via GitHub)" <gi...@apache.org> on 2026/08/17 16:50:09 UTC
[PR] CAMEL-24398: Fix hasAttachments() for empty attachment trait map [camel]
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-24398: Fix hasAttachments() for empty attachment trait map [camel]
Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier merged PR #25523:
URL: https://github.com/apache/camel/pull/25523
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-24398: Fix hasAttachments() for empty attachment trait map [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #25523:
URL: https://github.com/apache/camel/pull/25523#issuecomment-5394784799
<!-- ci-tested-modules -->
:test_tube: **CI tested the following changed modules:**
- `components/camel-attachments`
> :information_source: Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the `test-dependents` label to force testing all dependents.
---
<details><summary>:microscope: Scalpel shadow comparison — Scalpel: 85 tested, 29 compile-only — current: 85 all tested</summary>
[Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **114 affected modules** (current approach: 85).
<details><summary>:warning: Modules only in Scalpel (29)</summary>
- `apache-camel`
- `camel-allcomponents`
- `camel-catalog`
- `camel-catalog-console`
- `camel-catalog-lucene`
- `camel-catalog-maven`
- `camel-catalog-suggest`
- `camel-componentdsl`
- `camel-csimple-maven-plugin`
- `camel-endpointdsl`
- `camel-endpointdsl-support`
- `camel-itest`
- `camel-jbang-core`
- `camel-jbang-it`
- `camel-jbang-main`
- `camel-jbang-plugin-edit`
- `camel-jbang-plugin-generate`
- `camel-jbang-plugin-kubernetes`
- `camel-jbang-plugin-test`
- `camel-kamelet-main`
- `camel-launcher`
- `camel-report-maven-plugin`
- `camel-route-parser`
- `camel-yaml-dsl`
- `camel-yaml-dsl-deserializers`
- `camel-yaml-dsl-maven-plugin`
- `coverage`
- `docs`
- `dummy-component`
</details>
**Skip-tests mode would test 85 modules** (1 direct + 84 downstream), **skip tests for 29** (generated code, meta-modules)
<details><summary>Modules Scalpel would test (85)</summary>
- `camel-a2a`
- `camel-ai-observability`
- `camel-as2`
- `camel-atmosphere-websocket`
- `camel-attachments`
- `camel-clickup`
- `camel-consul`
- `camel-csimple-joor`
- `camel-cxf-common`
- `camel-cxf-rest`
- `camel-cxf-soap`
- `camel-cxf-spring-common`
- `camel-cxf-spring-rest`
- `camel-cxf-spring-soap`
- `camel-cxf-spring-transport`
- `camel-cxf-transport`
- `camel-freemarker`
- `camel-graphql`
- `camel-groovy`
- `camel-http`
- `camel-http-common`
- `camel-iso8583`
- `camel-java-joor-dsl`
- `camel-jbang-mcp`
- `camel-jbang-plugin-mcp`
- `camel-jbang-plugin-route-parser`
- `camel-jbang-plugin-tui`
- `camel-jbang-plugin-validate`
- `camel-jetty`
- `camel-jetty-common`
- `camel-jsonpath`
- `camel-kamelet`
- `camel-knative-http`
- `camel-kubernetes`
- `camel-langchain4j-chat`
- `camel-langchain4j-embeddings`
- `camel-langchain4j-embeddingstore`
- `camel-langchain4j-tools`
- `camel-launcher-container`
- `camel-lra`
- `camel-mail`
- `camel-mail-microsoft-oauth`
- `camel-mcp-server`
- `camel-micrometer-observability`
- `camel-micrometer-prometheus`
- `camel-netty-http`
- `camel-oauth`
- `camel-observability-services`
- `camel-once`
- `camel-openai`
- `camel-openapi-validator`
- `camel-opentelemetry`
- `camel-opentelemetry2`
- `camel-platform-http`
- `camel-platform-http-jolokia`
- `camel-platform-http-main`
- `camel-platform-http-vertx`
- `camel-quickfix`
- `camel-rest-openapi`
- `camel-rest-postman`
- `camel-restdsl-openapi-plugin`
- `camel-sap-netweaver`
- `camel-servlet`
- `camel-slack`
- `camel-smooks`
- `camel-soap`
- `camel-spring-rabbitmq`
- `camel-spring-ws`
- `camel-telegram`
- `camel-telemetry`
- `camel-telemetry-dev`
- `camel-test-main-junit5`
- `camel-test-main-junit6`
- `camel-undertow`
- `camel-undertow-spring-security`
- `camel-vertx-http`
- `camel-webhook`
- `camel-whatsapp`
- `camel-xml-io-dsl`
- `camel-xml-jaxb-dsl`
- `camel-xml-jaxb-dsl-test-definition`
- `camel-xml-jaxb-dsl-test-spring`
- `camel-yaml-dsl-validator`
- `camel-yaml-dsl-validator-maven-plugin`
- `camel-zookeeper`
</details>
<details><summary>Modules with tests skipped (29)</summary>
- `apache-camel`
- `camel-allcomponents`
- `camel-catalog`
- `camel-catalog-console`
- `camel-catalog-lucene`
- `camel-catalog-maven`
- `camel-catalog-suggest`
- `camel-componentdsl`
- `camel-csimple-maven-plugin`
- `camel-endpointdsl`
- `camel-endpointdsl-support`
- `camel-itest`
- `camel-jbang-core`
- `camel-jbang-it`
- `camel-jbang-main`
- `camel-jbang-plugin-edit`
- `camel-jbang-plugin-generate`
- `camel-jbang-plugin-kubernetes`
- `camel-jbang-plugin-test`
- `camel-kamelet-main`
- `camel-launcher`
- `camel-report-maven-plugin`
- `camel-route-parser`
- `camel-yaml-dsl`
- `camel-yaml-dsl-deserializers`
- `camel-yaml-dsl-maven-plugin`
- `coverage`
- `docs`
- `dummy-component`
</details>
> :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
</details>
<details><summary>Build reactor — dependencies compiled but only changed modules were tested (114 modules)</summary>
- Camel :: AI :: A2A
- Camel :: AI :: LangChain4j :: Chat
- Camel :: AI :: LangChain4j :: Embedding
- Camel :: AI :: LangChain4j :: EmbeddingStore
- Camel :: AI :: LangChain4j :: Tools (deprecated)
- Camel :: AI :: MCP Server
- Camel :: AI :: Observability
- Camel :: AI :: OpenAI
- Camel :: AS2 :: Component
- Camel :: All Components Sync point
- Camel :: Assembly
- Camel :: Atmosphere WebSocket Servlet
- Camel :: Attachments
- Camel :: CXF :: Common
- Camel :: CXF :: Common :: Spring
- Camel :: CXF :: REST
- Camel :: CXF :: REST :: Spring
- Camel :: CXF :: SOAP
- Camel :: CXF :: SOAP :: Spring
- Camel :: CXF :: Transport
- Camel :: CXF :: Transport :: Spring
- Camel :: Catalog :: CSimple Maven Plugin (deprecated)
- Camel :: Catalog :: Camel Catalog
- Camel :: Catalog :: Camel Report Maven Plugin
- Camel :: Catalog :: Camel Route Parser
- Camel :: Catalog :: Console
- Camel :: Catalog :: Dummy Component
- Camel :: Catalog :: Lucene (deprecated)
- Camel :: Catalog :: Maven
- Camel :: Catalog :: Suggest
- Camel :: ClickUp
- Camel :: Common Telemetry
- Camel :: Component DSL
- Camel :: Consul
- Camel :: Coverage
- Camel :: Docs
- Camel :: Endpoint DSL
- Camel :: Endpoint DSL :: Support
- Camel :: Freemarker
- Camel :: GraphQL
- Camel :: Groovy
- Camel :: HTTP
- Camel :: HTTP :: Common
- Camel :: ISO-8583
- Camel :: Integration Tests
- Camel :: JBang :: Core
- Camel :: JBang :: Integration tests
- Camel :: JBang :: MCP
- Camel :: JBang :: Main
- Camel :: JBang :: Plugin :: Edit
- Camel :: JBang :: Plugin :: Generate
- Camel :: JBang :: Plugin :: Kubernetes
- Camel :: JBang :: Plugin :: MCP
- Camel :: JBang :: Plugin :: Route Parser
- Camel :: JBang :: Plugin :: TUI
- Camel :: JBang :: Plugin :: Testing
- Camel :: JBang :: Plugin :: Validate
- Camel :: JSon Path
- Camel :: Java DSL with jOOR
- Camel :: Jetty
- Camel :: Jetty :: Common
- Camel :: Kamelet
- Camel :: Kamelet Main
- Camel :: Knative HTTP
- Camel :: Kubernetes
- Camel :: Launcher
- Camel :: Launcher :: Container
- Camel :: Long-Running-Action
- Camel :: Mail
- Camel :: Mail :: Microsoft OAuth
- Camel :: Maven Plugins :: OpenApi REST DSL Generator
- Camel :: Micrometer :: Observability 2
- Camel :: Micrometer :: Prometheus
- Camel :: Netty HTTP
- Camel :: OAuth
- Camel :: Observability Services
- Camel :: Once
- Camel :: OpenAPI :: Validator
- Camel :: OpenTelemetry (deprecated)
- Camel :: Opentelemetry 2
- Camel :: Platform HTTP
- Camel :: Platform HTTP :: Jolokia
- Camel :: Platform HTTP :: Main
- Camel :: Platform HTTP :: Vert.x
- Camel :: QuickFIX/J
- Camel :: REST OpenApi
- Camel :: REST Postman
- Camel :: SAP NetWeaver
- Camel :: SOAP
- Camel :: Servlet
- Camel :: Slack
- Camel :: Smooks :: Parent
- Camel :: Spring RabbitMQ
- Camel :: Spring Web Services
- Camel :: Telegram
- Camel :: Telemetry :: Dev
- Camel :: Test :: Main :: JUnit5
- Camel :: Test :: Main :: JUnit6
- Camel :: Undertow
- Camel :: Undertow Spring Security
- Camel :: Vert.x :: HTTP
- Camel :: Webhook
- Camel :: Whatsapp
- Camel :: XML DSL Jaxb :: Test :: Definition
- Camel :: XML DSL Jaxb :: Test :: Spring
- Camel :: XML DSL with camel-xml-io
- Camel :: XML DSL with camel-xml-jaxb
- Camel :: YAML DSL
- Camel :: YAML DSL :: Deserializers
- Camel :: YAML DSL :: Maven Plugins
- Camel :: YAML DSL :: Validator
- Camel :: YAML DSL :: Validator Maven Plugin
- Camel :: Zookeeper
- Camel :: csimple jOOR (deprecated)
</details>
---
:gear: [View full build and test results](https://github.com/apache/camel/actions/runs/32047476064)
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-24398: Fix hasAttachments() for empty attachment trait map [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #25523:
URL: https://github.com/apache/camel/pull/25523#issuecomment-5394362808
:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: Apache Camel Committers, please review the following items:
* First-time contributors **require MANUAL approval** for the GitHub Actions to run
* You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
* You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
* Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
:warning: Be careful when sharing logs. Review their contents before sharing them publicly.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org