You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2026/07/20 08:53:52 UTC

(camel) branch fix/CAMEL-24180 created (now 3db74c2c48fe)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch fix/CAMEL-24180
in repository https://gitbox.apache.org/repos/asf/camel.git


      at 3db74c2c48fe CAMEL-24180: Fix CxfMessageHelper fallback setting null instead of actual body

This branch includes the following new commits:

     new 3db74c2c48fe CAMEL-24180: Fix CxfMessageHelper fallback setting null instead of actual body

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(camel) 01/01: CAMEL-24180: Fix CxfMessageHelper fallback setting null instead of actual body

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch fix/CAMEL-24180
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 3db74c2c48fee5d96f6b5de88efca3ca0034c55a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Jul 20 10:53:38 2026 +0200

    CAMEL-24180: Fix CxfMessageHelper fallback setting null instead of actual body
    
    Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
    Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
 .../cxf/transport/message/CxfMessageHelper.java    |  2 +-
 .../cxf/common/message/CxfMessageHelperTest.java   | 29 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/components/camel-cxf/camel-cxf-transport/src/main/java/org/apache/camel/component/cxf/transport/message/CxfMessageHelper.java b/components/camel-cxf/camel-cxf-transport/src/main/java/org/apache/camel/component/cxf/transport/message/CxfMessageHelper.java
index 31e3d35c1a8c..e5c587082de1 100644
--- a/components/camel-cxf/camel-cxf-transport/src/main/java/org/apache/camel/component/cxf/transport/message/CxfMessageHelper.java
+++ b/components/camel-cxf/camel-cxf-transport/src/main/java/org/apache/camel/component/cxf/transport/message/CxfMessageHelper.java
@@ -60,7 +60,7 @@ public final class CxfMessageHelper {
             answer.setContent(InputStream.class, body);
         } else if (message.getBody() != null) {
             // fallback and set the body as what it is
-            answer.setContent(Object.class, body);
+            answer.setContent(Object.class, message.getBody());
         }
 
         answer.putAll(message.getHeaders());
diff --git a/components/camel-cxf/camel-cxf-transport/src/test/java/org/apache/camel/component/cxf/common/message/CxfMessageHelperTest.java b/components/camel-cxf/camel-cxf-transport/src/test/java/org/apache/camel/component/cxf/common/message/CxfMessageHelperTest.java
index 2b1a4fd66d91..12cf3df8e5a9 100644
--- a/components/camel-cxf/camel-cxf-transport/src/test/java/org/apache/camel/component/cxf/common/message/CxfMessageHelperTest.java
+++ b/components/camel-cxf/camel-cxf-transport/src/test/java/org/apache/camel/component/cxf/common/message/CxfMessageHelperTest.java
@@ -42,6 +42,8 @@ import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class CxfMessageHelperTest {
@@ -105,6 +107,33 @@ public class CxfMessageHelperTest {
         assertEquals(values.get(0), value, "The value must match");
     }
 
+    @Test
+    public void testGetCxfInMessageWithPojoBody() throws Exception {
+        HeaderFilterStrategy headerFilterStrategy = new CxfHeaderFilterStrategy();
+        Exchange exchange = new DefaultExchange(context);
+
+        Object pojo = List.of("item1", "item2");
+        exchange.getIn().setBody(pojo);
+
+        Message message = CxfMessageHelper.getCxfInMessage(headerFilterStrategy, exchange, false);
+
+        assertNull(message.getContent(InputStream.class), "POJO should not be convertible to InputStream");
+        assertSame(pojo, message.getContent(Object.class), "Fallback must set the original POJO body");
+    }
+
+    @Test
+    public void testGetCxfInMessageWithNullBody() throws Exception {
+        HeaderFilterStrategy headerFilterStrategy = new CxfHeaderFilterStrategy();
+        Exchange exchange = new DefaultExchange(context);
+
+        exchange.getIn().setBody(null);
+
+        Message message = CxfMessageHelper.getCxfInMessage(headerFilterStrategy, exchange, false);
+
+        assertNull(message.getContent(InputStream.class), "Null body should produce no InputStream content");
+        assertNull(message.getContent(Object.class), "Null body should produce no Object content");
+    }
+
     private String toString(InputStream is) throws IOException {
         StringBuilder out = new StringBuilder();
         CachedOutputStream os = new CachedOutputStream();