You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/12/09 13:18:38 UTC

[camel] 05/06: CAMEL-17291 - Camel-AWS2-SES: Don't set the replyTo/to addresses as List

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

acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit eee5ceb1dd36854cd134107309ec66f2ead821a6
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Dec 9 14:12:05 2021 +0100

    CAMEL-17291 - Camel-AWS2-SES: Don't set the replyTo/to addresses as List
---
 .../camel/component/aws2/ses/Ses2Producer.java     | 22 ++++++++++++++++------
 .../aws2/ses/integration/SesComponentManualIT.java |  4 +---
 2 files changed, 17 insertions(+), 9 deletions(-)

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 aedf021..9cbca41 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
@@ -20,6 +20,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
 import java.nio.ByteBuffer;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -28,6 +29,7 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -128,9 +130,13 @@ public class Ses2Producer extends DefaultProducer {
         if (replyToAddresses == null) {
             replyToAddresses = getConfiguration().getReplyToAddresses();
         }
-        return Stream.of(replyToAddresses.split(","))
-                .map(String::trim)
-                .collect(Collectors.toList());
+        if (ObjectHelper.isNotEmpty(replyToAddresses)) {
+            return Stream.of(replyToAddresses.split(","))
+                    .map(String::trim)
+                    .collect(Collectors.toList());
+        } else {
+            return Collections.emptyList();
+        }
     }
 
     private String determineReturnPath(Exchange exchange) {
@@ -157,9 +163,13 @@ public class Ses2Producer extends DefaultProducer {
         if (to == null) {
             to = getConfiguration().getTo();
         }
-        return Stream.of(to.split(","))
-                .map(String::trim)
-                .collect(Collectors.toList());
+        if (ObjectHelper.isNotEmpty(to)) {
+            return Stream.of(to.split(","))
+                    .map(String::trim)
+                    .collect(Collectors.toList());
+        } else {
+            return Collections.emptyList();
+        }
     }
 
     private String determineFrom(Exchange exchange) {
diff --git a/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/integration/SesComponentManualIT.java b/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/integration/SesComponentManualIT.java
index 0c2b700..78f139b 100644
--- a/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/integration/SesComponentManualIT.java
+++ b/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/integration/SesComponentManualIT.java
@@ -16,8 +16,6 @@
  */
 package org.apache.camel.component.aws2.ses.integration;
 
-import java.util.Collections;
-
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Processor;
@@ -42,7 +40,7 @@ public class SesComponentManualIT extends CamelTestSupport {
         Exchange exchange = template.send("direct:start", ExchangePattern.InOnly, new Processor() {
             public void process(Exchange exchange) throws Exception {
                 exchange.getIn().setHeader(Ses2Constants.SUBJECT, "This is my subject");
-                exchange.getIn().setHeader(Ses2Constants.TO, Collections.singletonList("to@example.com"));
+                exchange.getIn().setHeader(Ses2Constants.TO, "to@example.com");
                 exchange.getIn().setBody("This is my message text.");
             }
         });