INT-4500: Fix DefAmqpHeaderMapper correlationId
JIRA https://jira.spring.io/browse/INT-4500 The `correlationId` condition was against a `contentType` by mistake * Code style polishing, add `@author`
This commit is contained in:
committed by
Artem Bilan
parent
e40e2a4238
commit
0dcbde0642
@@ -53,11 +53,13 @@ import org.springframework.util.StringUtils;
|
|||||||
* @author Gary Russell
|
* @author Gary Russell
|
||||||
* @author Artem Bilan
|
* @author Artem Bilan
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
|
* @author Steve Singer
|
||||||
|
*
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public class DefaultAmqpHeaderMapper extends AbstractHeaderMapper<MessageProperties> implements AmqpHeaderMapper {
|
public class DefaultAmqpHeaderMapper extends AbstractHeaderMapper<MessageProperties> implements AmqpHeaderMapper {
|
||||||
|
|
||||||
private static final List<String> STANDARD_HEADER_NAMES = new ArrayList<String>();
|
private static final List<String> STANDARD_HEADER_NAMES = new ArrayList<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
STANDARD_HEADER_NAMES.add(AmqpHeaders.APP_ID);
|
STANDARD_HEADER_NAMES.add(AmqpHeaders.APP_ID);
|
||||||
@@ -126,7 +128,7 @@ public class DefaultAmqpHeaderMapper extends AbstractHeaderMapper<MessagePropert
|
|||||||
headers.put(AmqpHeaders.CONTENT_TYPE, contentType);
|
headers.put(AmqpHeaders.CONTENT_TYPE, contentType);
|
||||||
}
|
}
|
||||||
String correlationId = amqpMessageProperties.getCorrelationId();
|
String correlationId = amqpMessageProperties.getCorrelationId();
|
||||||
if (StringUtils.hasText(contentType)) {
|
if (StringUtils.hasText(correlationId)) {
|
||||||
headers.put(AmqpHeaders.CORRELATION_ID, correlationId);
|
headers.put(AmqpHeaders.CORRELATION_ID, correlationId);
|
||||||
}
|
}
|
||||||
MessageDeliveryMode receivedDeliveryMode = amqpMessageProperties.getReceivedDeliveryMode();
|
MessageDeliveryMode receivedDeliveryMode = amqpMessageProperties.getReceivedDeliveryMode();
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ import org.springframework.util.MimeTypeUtils;
|
|||||||
* @author Oleg Zhurakousky
|
* @author Oleg Zhurakousky
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @author Artem Bilan
|
* @author Artem Bilan
|
||||||
|
* @author Steve Singer
|
||||||
|
*
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public class DefaultAmqpHeaderMapperTests {
|
public class DefaultAmqpHeaderMapperTests {
|
||||||
@@ -213,6 +215,20 @@ public class DefaultAmqpHeaderMapperTests {
|
|||||||
assertEquals("test.replyTo2", headerMap.get(AmqpHeaders.SPRING_REPLY_TO_STACK));
|
assertEquals("test.replyTo2", headerMap.get(AmqpHeaders.SPRING_REPLY_TO_STACK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void toHeadersNonContenType() {
|
||||||
|
DefaultAmqpHeaderMapper headerMapper = DefaultAmqpHeaderMapper.inboundMapper();
|
||||||
|
MessageProperties amqpProperties = new MessageProperties();
|
||||||
|
amqpProperties.setAppId("test.appId");
|
||||||
|
amqpProperties.setClusterId("test.clusterId");
|
||||||
|
amqpProperties.setContentType(null);
|
||||||
|
String testCorrelationId = "foo";
|
||||||
|
amqpProperties.setCorrelationId(testCorrelationId);
|
||||||
|
Map<String, Object> headerMap = headerMapper.toHeadersFromReply(amqpProperties);
|
||||||
|
assertEquals(testCorrelationId, headerMap.get(AmqpHeaders.CORRELATION_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToHeadersConsumerMetadata() {
|
public void testToHeadersConsumerMetadata() {
|
||||||
DefaultAmqpHeaderMapper headerMapper = DefaultAmqpHeaderMapper.inboundMapper();
|
DefaultAmqpHeaderMapper headerMapper = DefaultAmqpHeaderMapper.inboundMapper();
|
||||||
|
|||||||
Reference in New Issue
Block a user