Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.UnsupportedOperationException: MessageHeaders is immutable if I add header in the handler

I have following line in my handler:

headers.put(EMPTY_FILE, true);

It is a reason of:

2019-11-26 13:36:29.420 ERROR 2216 --- [sub-subscriber3] o.s.integration.handler.LoggingHandler   : ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: error occurred during processing message in 'MethodInvokingMessageProcessor' [org.springframework.integration.handler.MethodInvokingMessageProcessor@319058ce]; nested exception is java.lang.UnsupportedOperationException: MessageHeaders is immutable, failedMessage=GenericMessage...

How could I fix it ?

like image 828
gstackoverflow Avatar asked Dec 04 '25 17:12

gstackoverflow


1 Answers

MessageHeaders is read-only. You can only copy exists headers to new map (include your own header too) and create NEW MessageHeader from this map.

like image 51
Nick Avatar answered Dec 07 '25 05:12

Nick