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

oscerd pushed a commit to branch camel-4.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.14.x by this push:
     new 3cda3df1b70d CAMEL-24238: camel-aws2-ses - send RawMessage body 
content instead of the SdkBytes descriptor (#25017)
3cda3df1b70d is described below

commit 3cda3df1b70d1267835e7f8faf0976bf91a3931b
Author: Andrea Cosentino <[email protected]>
AuthorDate: Thu Jul 23 15:23:22 2026 +0200

    CAMEL-24238: camel-aws2-ses - send RawMessage body content instead of the 
SdkBytes descriptor (#25017)
    
    When the exchange body is an SES RawMessage, Ses2Producer built the outgoing
    Content from the body converted to String, which for a RawMessage falls back
    to Object.toString() on the SDK type. SdkBytes.toString() renders a debug
    descriptor ("SdkBytes(bytes=0x46726f6d...)"), so the recipient received that
    descriptor instead of the MIME payload.
    
    Read the payload from RawMessage.data().asUtf8String() when the body is a
    RawMessage, and cover it with a test asserting the sent text equals the
    original MIME content.
    
    
    
    (cherry picked from commit b100364e864c41a014800346d6c3cc1a6d8831c9)
    
    Signed-off-by: Andrea Cosentino <[email protected]>
    Co-authored-by: Claude Opus 4.8 <[email protected]>
---
 components/camel-aws/camel-aws2-ses/pom.xml                |  5 +++++
 .../org/apache/camel/component/aws2/ses/Ses2Producer.java  |  3 ++-
 .../apache/camel/component/aws2/ses/SesComponentTest.java  | 14 ++++++++++++++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws/camel-aws2-ses/pom.xml 
b/components/camel-aws/camel-aws2-ses/pom.xml
index 6175d403bbf5..44801fb2ac59 100644
--- a/components/camel-aws/camel-aws2-ses/pom.xml
+++ b/components/camel-aws/camel-aws2-ses/pom.xml
@@ -80,5 +80,10 @@
             <artifactId>camel-test-spring-junit5</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>
diff --git 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java
 
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java
index 6feec964451b..f3c4a893a615 100644
--- 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java
+++ 
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java
@@ -101,7 +101,8 @@ public class Ses2Producer extends DefaultProducer {
                 = software.amazon.awssdk.services.ses.model.Message.builder();
         String content;
         if (exchange.getIn().getBody() instanceof RawMessage raw) {
-            content = raw.data().toString();
+            // SdkBytes.toString() is a debug descriptor 
(SdkBytes(bytes=0x...)), not the payload
+            content = raw.data().asUtf8String();
         } else {
             content = exchange.getIn().getBody(String.class);
         }
diff --git 
a/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentTest.java
 
b/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentTest.java
index 936963872e9f..da952d47b368 100644
--- 
a/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentTest.java
+++ 
b/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentTest.java
@@ -26,9 +26,12 @@ import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.core.SdkBytes;
 import software.amazon.awssdk.services.ses.model.MessageTag;
+import software.amazon.awssdk.services.ses.model.RawMessage;
 import software.amazon.awssdk.services.ses.model.SendEmailRequest;
 
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.jupiter.api.Assertions.*;
 
 public class SesComponentTest extends CamelTestSupport {
@@ -36,6 +39,17 @@ public class SesComponentTest extends CamelTestSupport {
     @BindToRegistry("amazonSESClient")
     private AmazonSESClientMock sesClient = new AmazonSESClientMock();
 
+    @Test
+    void rawMessageBodyIsSentAsItsContentNotTheSdkBytesDescriptor() {
+        String mime = "From: [email protected]\r\nSubject: Subject\r\n\r\nThis 
is my message text.";
+        template.send("direct:start", exchange -> exchange.getIn().setBody(
+                
RawMessage.builder().data(SdkBytes.fromUtf8String(mime)).build()));
+
+        // SdkBytes.toString() would yield "SdkBytes(bytes=0x...)" rather than 
the message content
+        String sent = 
sesClient.getSendEmailRequest().message().body().text().data();
+        assertThat(sent).isEqualTo(mime);
+    }
+
     @Test
     public void sendInOnlyMessageUsingUrlOptions() {
         Exchange exchange = template.send("direct:start", new Processor() {

Reply via email to