Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Commit 6aba36e

Browse files
chrylisartembilan
authored andcommitted
GH-214: Filter out nativeHeaders header for SNS mapping
Fixes #214 **Cherry-pick to `2.5.x`**
1 parent 993982d commit 6aba36e

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/main/java/org/springframework/integration/aws/support/AbstractMessageAttributesHeaderMapper.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2021 the original author or authors.
2+
* Copyright 2018-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
import org.springframework.integration.mapping.HeaderMapper;
2828
import org.springframework.integration.support.utils.PatternMatchUtils;
2929
import org.springframework.messaging.MessageHeaders;
30+
import org.springframework.messaging.support.NativeMessageHeaderAccessor;
3031
import org.springframework.util.Assert;
3132
import org.springframework.util.MimeType;
3233
import org.springframework.util.NumberUtils;
@@ -41,14 +42,22 @@
4142
*
4243
* @param <A> the target message attribute type.
4344
* @author Artem Bilan
45+
* @author Christopher Smith
4446
* @since 2.0
4547
*/
4648
public abstract class AbstractMessageAttributesHeaderMapper<A> implements HeaderMapper<Map<String, A>> {
4749

4850
private static final Log logger = LogFactory.getLog(SqsHeaderMapper.class);
4951

50-
private volatile String[] outboundHeaderNames = {"!" + MessageHeaders.ID, "!" + MessageHeaders.TIMESTAMP,
51-
"!" + AwsHeaders.MESSAGE_ID, "!" + AwsHeaders.QUEUE, "!" + AwsHeaders.TOPIC, "*"};
52+
private volatile String[] outboundHeaderNames = {
53+
"!" + MessageHeaders.ID,
54+
"!" + MessageHeaders.TIMESTAMP,
55+
"!" + NativeMessageHeaderAccessor.NATIVE_HEADERS,
56+
"!" + AwsHeaders.MESSAGE_ID,
57+
"!" + AwsHeaders.QUEUE,
58+
"!" + AwsHeaders.TOPIC,
59+
"*",
60+
};
5261

5362
/**
5463
* Provide the header names that should be mapped to a AWS request object attributes
@@ -58,8 +67,10 @@ public abstract class AbstractMessageAttributesHeaderMapper<A> implements Header
5867
* the names starting with {@code !} symbol, you have to escape it prepending with the
5968
* {@code \} symbol in the pattern definition. Defaults to map all ({@code *}) if the
6069
* type is supported by SQS. The {@link MessageHeaders#ID},
61-
* {@link MessageHeaders#TIMESTAMP}, {@link AwsHeaders#MESSAGE_ID},
62-
* {@link AwsHeaders#QUEUE} and {@link AwsHeaders#TOPIC} are ignored by default.
70+
* {@link MessageHeaders#TIMESTAMP},
71+
* {@link NativeMessageHeaderAccessor.NATIVE_HEADERS},
72+
* {@link AwsHeaders#MESSAGE_ID}, {@link AwsHeaders#QUEUE}, and
73+
* {@link AwsHeaders#TOPIC} are ignored by default.
6374
* @param outboundHeaderNames The inbound header names.
6475
*/
6576
public void setOutboundHeaderNames(String... outboundHeaderNames) {

0 commit comments

Comments
 (0)