Skip to content

Keep original headers when build ErrorMessage in DefaultErrorMessageStrategy#11160

Open
mjd507 wants to merge 1 commit into
spring-projects:mainfrom
mjd507:error-message-user-headers-missing
Open

Keep original headers when build ErrorMessage in DefaultErrorMessageStrategy#11160
mjd507 wants to merge 1 commit into
spring-projects:mainfrom
mjd507:error-message-user-headers-missing

Conversation

@mjd507

@mjd507 mjd507 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

When setup RequestHandlerRetryAdvice with a recover ErrorMessageSendingRecoverer, after retry exhausted, the DefaultErrorMessageStrategy will build a ErrorMessage, however it does not copy the original message headers.

because I need the header values to do the error routing, so I think it is useful to keep it.

…Strategy`

Signed-off-by: Jiandong Ma <jiandong.ma.cn@gmail.com>
if (inputMessage instanceof Message) {
return new ErrorMessage(throwable, (Message<?>) inputMessage);
if (inputMessage instanceof Message<?> message) {
return new ErrorMessage(throwable, message.getHeaders(), message);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I don't see a harm in this, but still in consistency with our support and compatibility policy, we cannot accept this right now.
This is some kind of breaking change, so we aim it for the next minor 7.2 starting in August.
Please, consider to mention this in the class Javadoc.
Also describe such a logic in the dedicated Error Handling chapter of the doc: https://docs.spring.io/spring-integration/reference/error-handling.html.

When we switch to new version, we will also ask you to add a note about this change in the whats-new.adoc dedicated to that new 7.2 version.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants