Federico Mariani created CAMEL-24180:
----------------------------------------
Summary: camel-cxf - CxfMessageHelper fallback drops
non-InputStream message bodies (sets null)
Key: CAMEL-24180
URL: https://issues.apache.org/jira/browse/CAMEL-24180
Project: Camel
Issue Type: Bug
Components: camel-cxf
Reporter: Federico Mariani
Assignee: Federico Mariani
*Severity:* High *[reproducer attached]*
h3. Problem
In the {{camel://}} transport, {{CxfMessageHelper.getCxfInMessage}} sets the
CXF message content from the Camel body:
{code:java}
InputStream body = message.getBody(InputStream.class);
if (body != null) {
answer.setContent(InputStream.class, body);
} else if (message.getBody() != null) {
// fallback and set the body as what it is
answer.setContent(Object.class, body); // body is provably null in this
branch
}
{code}
In the {{else if}} branch {{body}} is by definition {{null}} (that is the only
way to reach it), so the "fallback and set the body as what it is" comment is
not honoured - the intended value is {{message.getBody()}}. A copy-paste defect
dormant since the 2010 module split; the existing {{CxfMessageHelperTest}} only
covers String/DOMSource/File bodies (all InputStream-convertible), so the
branch is untested.
h3. Impact
A Camel body with no registered {{InputStream}} type converter (e.g. a POJO)
sent into a {{camel://}} destination, or returned to a {{camel://}} conduit,
produces a CXF message with *no content*; downstream CXF interceptors see an
empty message and fail with an unrelated parse/empty-envelope error.
h3. Location
{{components/camel-cxf/camel-cxf-transport/src/main/java/org/apache/camel/component/cxf/transport/message/CxfMessageHelper.java}}
~61-63.
h3. Fix
{code:java}
answer.setContent(Object.class, message.getBody());
{code}
h3. Reproducer
{{CxfMessageHelperPojoBodyReproducerTest}} (attached): a non-Serializable POJO
body yields null CXF content. Fails on current {{main}}.
----
_Filed by Claude Code (Claude Fable) on behalf of Federico Mariani (GitHub:
Croway). Findings from an AI-assisted code review of the camel-cxf component
family; each item was verified against the current source and git history.
Items marked *[reproducer attached]* include a failing JUnit test that
demonstrates the defect._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)