From 6afbac4b5d39b076fa6092059a01700e283ef4a3 Mon Sep 17 00:00:00 2001 From: abilan Date: Tue, 3 Jan 2023 13:24:39 -0500 Subject: [PATCH] GH-218: Fix logging for AbstMesAttrsHeaderMapper Fixes https://github.com/spring-projects/spring-integration-aws/issues/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`** --- .../AbstractMessageAttributesHeaderMapper.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/springframework/integration/aws/support/AbstractMessageAttributesHeaderMapper.java b/src/main/java/org/springframework/integration/aws/support/AbstractMessageAttributesHeaderMapper.java index f0bc1a8..e387f4e 100644 --- a/src/main/java/org/springframework/integration/aws/support/AbstractMessageAttributesHeaderMapper.java +++ b/src/main/java/org/springframework/integration/aws/support/AbstractMessageAttributesHeaderMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2022 the original author or authors. + * Copyright 2018-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,13 +41,15 @@ import io.awspring.cloud.messaging.core.MessageAttributeDataTypes; * The {@link #toHeaders(Map)} is not supported. * * @param the target message attribute type. + * * @author Artem Bilan * @author Christopher Smith + * * @since 2.0 */ public abstract class AbstractMessageAttributesHeaderMapper implements HeaderMapper> { - private static final Log logger = LogFactory.getLog(SqsHeaderMapper.class); + protected final Log logger = LogFactory.getLog(getClass()); private volatile String[] outboundHeaderNames = { "!" + MessageHeaders.ID, @@ -104,10 +106,10 @@ public abstract class AbstractMessageAttributesHeaderMapper implements Header getBinaryMessageAttribute(ByteBuffer.wrap((byte[]) messageHeaderValue))); } else { - if (logger.isWarnEnabled()) { - logger.warn(String.format( + if (this.logger.isWarnEnabled()) { + this.logger.warn(String.format( "Message header with name '%s' and type '%s' cannot be sent as" - + " message attribute because it is not supported by SQS.", + + " message attribute because it is not supported by the current AWS service.", messageHeaderName, messageHeaderValue.getClass().getName())); } }