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 b7f78292e747 CAMEL-23506: align aws2-sqs/sns HeaderFilterStrategy with
siblings (#23373)
b7f78292e747 is described below
commit b7f78292e747a28dbf5da444265557b5f9f3c1a1
Author: Andrea Cosentino <[email protected]>
AuthorDate: Wed May 20 15:01:47 2026 +0200
CAMEL-23506: align aws2-sqs/sns HeaderFilterStrategy with siblings (#23373)
Sqs2HeaderFilterStrategy and Sns2HeaderFilterStrategy only configured
an outbound filter. Add setInFilterStartsWith(CAMEL_FILTER_STARTS_WITH)
so the inbound direction is aligned with the sibling strategies
(Kafka, Mail, CoAP, Google Pub/Sub, ...). The existing outbound regex
(which also catches breadcrumbId and org.apache.camel.*) is unchanged.
Includes focused unit tests in both modules and the
camel-4x-upgrade-guide-4_14.adoc note.
(cherry picked from commit 5f57258fb33d33ef99df10594f8fe9f11d7c2b7e)
JIRA: https://issues.apache.org/jira/browse/CAMEL-23506
Closes #23221
---
.../aws2/sns/Sns2HeaderFilterStrategy.java | 1 +
.../aws2/sns/Sns2HeaderFilterStrategyTest.java | 53 +++++++++++++++++++++
.../aws2/sqs/Sqs2HeaderFilterStrategy.java | 2 +-
.../aws2/sqs/Sqs2HeaderFilterStrategyTest.java | 54 ++++++++++++++++++++++
.../ROOT/pages/camel-4x-upgrade-guide-4_14.adoc | 19 ++++++++
5 files changed, 128 insertions(+), 1 deletion(-)
diff --git
a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2HeaderFilterStrategy.java
b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2HeaderFilterStrategy.java
index ab79fe430beb..fe85840d9ae9 100644
---
a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2HeaderFilterStrategy.java
+++
b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2HeaderFilterStrategy.java
@@ -28,5 +28,6 @@ public class Sns2HeaderFilterStrategy extends
DefaultHeaderFilterStrategy {
// filter headers begin with "Camel" or "org.apache.camel"
setOutFilterPattern("(breadcrumbId|Camel|org\\.apache\\.camel)[\\.|a-z|A-z|0-9]*");
+ setInFilterStartsWith(CAMEL_FILTER_STARTS_WITH);
}
}
diff --git
a/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2HeaderFilterStrategyTest.java
b/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2HeaderFilterStrategyTest.java
new file mode 100644
index 000000000000..be8f97be873f
--- /dev/null
+++
b/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2HeaderFilterStrategyTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.sns;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class Sns2HeaderFilterStrategyTest {
+
+ private final Sns2HeaderFilterStrategy strategy = new
Sns2HeaderFilterStrategy();
+
+ @Test
+ void inboundFiltersCamelPrefixedHeaders() {
+ assertTrue(strategy.applyFilterToExternalHeaders("CamelHttpUri",
"value", null));
+ assertTrue(strategy.applyFilterToExternalHeaders("CamelFileName",
"value", null));
+ assertTrue(strategy.applyFilterToExternalHeaders("camelfoo", "value",
null));
+ assertTrue(strategy.applyFilterToExternalHeaders("CAMELFOO", "value",
null));
+ }
+
+ @Test
+ void inboundAllowsNonCamelHeaders() {
+ assertFalse(strategy.applyFilterToExternalHeaders("X-Custom", "value",
null));
+ assertFalse(strategy.applyFilterToExternalHeaders("subject", "hello",
null));
+ }
+
+ @Test
+ void outboundFiltersCamelAndBreadcrumbHeaders() {
+ assertTrue(strategy.applyFilterToCamelHeaders("CamelHttpUri", "value",
null));
+
assertTrue(strategy.applyFilterToCamelHeaders("org.apache.camel.internal",
"value", null));
+ assertTrue(strategy.applyFilterToCamelHeaders("breadcrumbId", "value",
null));
+ }
+
+ @Test
+ void outboundAllowsUserHeaders() {
+ assertFalse(strategy.applyFilterToCamelHeaders("X-Custom", "value",
null));
+ }
+}
diff --git
a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2HeaderFilterStrategy.java
b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2HeaderFilterStrategy.java
index ee9e7ec85b7d..d6b460c53ece 100644
---
a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2HeaderFilterStrategy.java
+++
b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2HeaderFilterStrategy.java
@@ -27,6 +27,6 @@ public class Sqs2HeaderFilterStrategy extends
DefaultHeaderFilterStrategy {
setLowerCase(true);
// filter headers begin with "Camel" or "org.apache.camel"
setOutFilterPattern("(breadcrumbId|Camel|org\\.apache\\.camel)[\\.|a-z|A-z|0-9]*");
-
+ setInFilterStartsWith(CAMEL_FILTER_STARTS_WITH);
}
}
diff --git
a/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/Sqs2HeaderFilterStrategyTest.java
b/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/Sqs2HeaderFilterStrategyTest.java
new file mode 100644
index 000000000000..1c21bd469806
--- /dev/null
+++
b/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/Sqs2HeaderFilterStrategyTest.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.sqs;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class Sqs2HeaderFilterStrategyTest {
+
+ private final Sqs2HeaderFilterStrategy strategy = new
Sqs2HeaderFilterStrategy();
+
+ @Test
+ void inboundFiltersCamelPrefixedHeaders() {
+ assertTrue(strategy.applyFilterToExternalHeaders("CamelSqlQuery",
"value", null));
+ assertTrue(strategy.applyFilterToExternalHeaders("CamelHttpUri",
"value", null));
+ assertTrue(strategy.applyFilterToExternalHeaders("CamelFileName",
"value", null));
+ assertTrue(strategy.applyFilterToExternalHeaders("camelfoo", "value",
null));
+ assertTrue(strategy.applyFilterToExternalHeaders("CAMELFOO", "value",
null));
+ }
+
+ @Test
+ void inboundAllowsNonCamelHeaders() {
+ assertFalse(strategy.applyFilterToExternalHeaders("X-Custom", "value",
null));
+ assertFalse(strategy.applyFilterToExternalHeaders("orderId", "12345",
null));
+ }
+
+ @Test
+ void outboundFiltersCamelAndBreadcrumbHeaders() {
+ assertTrue(strategy.applyFilterToCamelHeaders("CamelHttpUri", "value",
null));
+
assertTrue(strategy.applyFilterToCamelHeaders("org.apache.camel.internal",
"value", null));
+ assertTrue(strategy.applyFilterToCamelHeaders("breadcrumbId", "value",
null));
+ }
+
+ @Test
+ void outboundAllowsUserHeaders() {
+ assertFalse(strategy.applyFilterToCamelHeaders("X-Custom", "value",
null));
+ }
+}
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
index 7a9c89ea4ce2..2d6206f48329 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
@@ -336,3 +336,22 @@ WebSocket query parameters before mapping them into the
Camel message headers. T
default `HttpHeaderFilterStrategy` filters headers starting with `Camel` /
`camel`
(case-insensitive). Routes that relied on receiving `Camel`-prefixed header
names from WebSocket
query parameters can supply a custom `headerFilterStrategy` to restore the
previous behaviour.
+
+=== camel-aws2-sqs
+
+`Sqs2HeaderFilterStrategy` now also configures an inbound filter aligned with
the existing
+outbound regex. Headers starting with `Camel` / `camel` (case-insensitive),
`breadcrumbId` and
+`org.apache.camel.*` are now filtered in both the inbound and outbound
directions, aligning the
+component with the rest of the Camel component catalog (`camel-kafka`,
`camel-mail`,
+`camel-coap`, `camel-google-pubsub`, ...). Routes that relied on receiving
these header names
+from inbound SQS messages can supply a custom `headerFilterStrategy` to
restore the previous
+behaviour.
+
+=== camel-aws2-sns
+
+`Sns2HeaderFilterStrategy` now also configures an inbound filter aligned with
the existing
+outbound regex. Headers starting with `Camel` / `camel` (case-insensitive),
`breadcrumbId` and
+`org.apache.camel.*` are now filtered in both the inbound and outbound
directions, aligning the
+component with the rest of the Camel component catalog. Routes that relied on
receiving these
+header names on inbound SNS messages can supply a custom
`headerFilterStrategy` to restore the
+previous behaviour.