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


The following commit(s) were added to refs/heads/main by this push:
     new eb9936a  CAMEL-16930 - Sns2Producer does not handle headers containing 
numbers, thanks to Simon Rasmussen for the patch
eb9936a is described below

commit eb9936a9c9146ea3e8811d66f3633e8ecd7e0342
Author: Andrea Cosentino <anco...@gmail.com>
AuthorDate: Thu Sep 9 06:51:55 2021 +0200

    CAMEL-16930 - Sns2Producer does not handle headers containing numbers, 
thanks to Simon Rasmussen for the patch
---
 .../main/java/org/apache/camel/component/aws2/sns/Sns2Producer.java  | 5 +++++
 .../java/org/apache/camel/component/aws2/sns/SnsProducerTest.java    | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git 
a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Producer.java
 
b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Producer.java
index 0309b32..66babdd 100644
--- 
a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Producer.java
+++ 
b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Producer.java
@@ -105,6 +105,11 @@ public class Sns2Producer extends DefaultProducer {
                     mav.dataType("String");
                     mav.stringValue((String) value);
                     result.put(entry.getKey(), mav.build());
+                } else if (value instanceof Number) {
+                    MessageAttributeValue.Builder mav = 
MessageAttributeValue.builder();
+                    mav.dataType("String");
+                    mav.stringValue(value.toString());
+                    result.put(entry.getKey(), mav.build());
                 } else if (value instanceof ByteBuffer) {
                     MessageAttributeValue.Builder mav = 
MessageAttributeValue.builder();
                     mav.dataType("Binary");
diff --git 
a/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/SnsProducerTest.java
 
b/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/SnsProducerTest.java
index bc01c7b..a780c49 100644
--- 
a/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/SnsProducerTest.java
+++ 
b/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/SnsProducerTest.java
@@ -58,10 +58,11 @@ public class SnsProducerTest {
         headers.put("key5", Arrays.asList("Value7", null, "Value9"));
         headers.put("key6", Arrays.asList(10, null, 12));
         headers.put("key7", Arrays.asList(true, null, false));
+        headers.put("key8", 42);
 
         Map<String, MessageAttributeValue> translateAttributes = 
producer.translateAttributes(headers, exchange);
 
-        assertThat(translateAttributes.size(), is(5));
+        assertThat(translateAttributes.size(), is(6));
         assertThat(translateAttributes.get("key3").dataType(), is("String"));
         assertThat(translateAttributes.get("key3").stringValue(), 
is("value3"));
         assertThat(translateAttributes.get("key4").dataType(), 
is("String.Array"));
@@ -69,5 +70,7 @@ public class SnsProducerTest {
         assertThat(translateAttributes.get("key5").stringValue(), 
is("[\"Value7\", null, \"Value9\"]"));
         assertThat(translateAttributes.get("key6").stringValue(), is("[10, 
null, 12]"));
         assertThat(translateAttributes.get("key7").stringValue(), is("[true, 
null, false]"));
+        assertThat(translateAttributes.get("key8").dataType(), is("String"));
+        assertThat(translateAttributes.get("key8").stringValue(), is("42"));
     }
 }

Reply via email to