|
16 | 16 |
|
17 | 17 | package org.springframework.integration.amqp.support; |
18 | 18 |
|
19 | | -import java.util.Collections; |
20 | 19 | import java.util.HashMap; |
21 | 20 | import java.util.Map; |
22 | 21 |
|
23 | 22 | import org.springframework.amqp.support.AmqpHeaders; |
24 | 23 | import org.springframework.core.AttributeAccessor; |
| 24 | +import org.springframework.integration.IntegrationMessageHeaderAccessor; |
25 | 25 | import org.springframework.integration.support.ErrorMessageStrategy; |
26 | 26 | import org.springframework.integration.support.ErrorMessageUtils; |
27 | 27 | import org.springframework.lang.Nullable; |
@@ -49,8 +49,11 @@ public class AmqpMessageHeaderErrorMessageStrategy implements ErrorMessageStrate |
49 | 49 | public ErrorMessage buildErrorMessage(Throwable throwable, @Nullable AttributeAccessor context) { |
50 | 50 | Object inputMessage = context == null ? null |
51 | 51 | : context.getAttribute(ErrorMessageUtils.INPUT_MESSAGE_CONTEXT_KEY); |
52 | | - Map<String, Object> headers = context == null ? new HashMap<String, Object>() : |
53 | | - Collections.singletonMap(AMQP_RAW_MESSAGE, context.getAttribute(AMQP_RAW_MESSAGE)); |
| 52 | + Map<String, Object> headers = new HashMap<String, Object>(); |
| 53 | + if (context != null) { |
| 54 | + headers.put(AMQP_RAW_MESSAGE, context.getAttribute(AMQP_RAW_MESSAGE)); |
| 55 | + headers.put(IntegrationMessageHeaderAccessor.SOURCE_DATA, context.getAttribute(AMQP_RAW_MESSAGE)); |
| 56 | + } |
54 | 57 | if (inputMessage instanceof Message) { |
55 | 58 | return new ErrorMessage(throwable, headers, (Message<?>) inputMessage); |
56 | 59 | } |
|
0 commit comments