Skip to content

Commit 577c2e8

Browse files
committed
Fix AbstractAwsMessageHandler impls for explicit headerMapper setting
1 parent 5cfdaa2 commit 577c2e8

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/main/java/org/springframework/integration/aws/outbound/AbstractAwsMessageHandler.java

+7
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public abstract class AbstractAwsMessageHandler<H> extends AbstractMessageProduc
6161

6262
private HeaderMapper<H> headerMapper;
6363

64+
private boolean headerMapperSet;
65+
6466
public void setSendTimeout(long sendTimeout) {
6567
setSendTimeoutExpression(new ValueExpression<>(sendTimeout));
6668
}
@@ -84,6 +86,11 @@ protected Expression getSendTimeoutExpression() {
8486
*/
8587
public void setHeaderMapper(HeaderMapper<H> headerMapper) {
8688
this.headerMapper = headerMapper;
89+
this.headerMapperSet = true;
90+
}
91+
92+
protected boolean isHeaderMapperSet() {
93+
return this.headerMapperSet;
8794
}
8895

8996
/**

src/main/java/org/springframework/integration/aws/outbound/SnsMessageHandler.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ public void setBodyExpression(Expression bodyExpression) {
187187
@Override
188188
protected void onInit() {
189189
super.onInit();
190-
setHeaderMapper(new SnsHeaderMapper());
190+
if (!isHeaderMapperSet()) {
191+
setHeaderMapper(new SnsHeaderMapper());
192+
}
191193
TypeLocator typeLocator = getEvaluationContext().getTypeLocator();
192194
if (typeLocator instanceof StandardTypeLocator standardTypeLocator) {
193195
/*

src/main/java/org/springframework/integration/aws/outbound/SqsMessageHandler.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ public void setMessageConverter(MessageConverter messageConverter) {
148148
@Override
149149
protected void onInit() {
150150
super.onInit();
151-
setHeaderMapper(new SqsHeaderMapper());
151+
if (!isHeaderMapperSet()) {
152+
setHeaderMapper(new SqsHeaderMapper());
153+
}
152154
if (this.messageConverter == null) {
153155
this.messageConverter = new GenericMessageConverter(getConversionService());
154156
}

0 commit comments

Comments
 (0)