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

Commit 6afbac4

Browse files
committed
GH-218: Fix logging for AbstMesAttrsHeaderMapper
Fixes #218 The `AbstractMessageAttributesHeaderMapper` incorrectly logs only for SQS service. * Fix `logger` property to be a `protected` and not `static` to make it rely on the `getClass()` context * Fix logging message in the `fromHeaders()` from just `SQS` to `the current AWS service` **Cherry-pick to `2.5.x`**
1 parent c74a7fa commit 6afbac4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2022 the original author or authors.
2+
* Copyright 2018-2023 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.
@@ -41,13 +41,15 @@
4141
* The {@link #toHeaders(Map)} is not supported.
4242
*
4343
* @param <A> the target message attribute type.
44+
*
4445
* @author Artem Bilan
4546
* @author Christopher Smith
47+
*
4648
* @since 2.0
4749
*/
4850
public abstract class AbstractMessageAttributesHeaderMapper<A> implements HeaderMapper<Map<String, A>> {
4951

50-
private static final Log logger = LogFactory.getLog(SqsHeaderMapper.class);
52+
protected final Log logger = LogFactory.getLog(getClass());
5153

5254
private volatile String[] outboundHeaderNames = {
5355
"!" + MessageHeaders.ID,
@@ -104,10 +106,10 @@ else if (messageHeaderValue instanceof byte[]) {
104106
getBinaryMessageAttribute(ByteBuffer.wrap((byte[]) messageHeaderValue)));
105107
}
106108
else {
107-
if (logger.isWarnEnabled()) {
108-
logger.warn(String.format(
109+
if (this.logger.isWarnEnabled()) {
110+
this.logger.warn(String.format(
109111
"Message header with name '%s' and type '%s' cannot be sent as"
110-
+ " message attribute because it is not supported by SQS.",
112+
+ " message attribute because it is not supported by the current AWS service.",
111113
messageHeaderName, messageHeaderValue.getClass().getName()));
112114
}
113115
}

0 commit comments

Comments
 (0)