Buggy code:
public class UserDestinationMessageHandler implements MessageHandler { private static final Log logger = LogFactory . getLog ( UserDestinationMessageHandler . class ) ; private final MessageSendingOperations < String > messagingTemplate ; private String destinationPrefix = "//user//" ; private UserQueueSuffixResolver userQueueSuffixResolver = new SimpleUserQueueSuffixResolver ( ) ; public UserDestinationMessageHandler ( MessageSendingOperations < String > messagingTemplate , UserQueueSuffixResolver userQueueSuffixResolver ) { } public void setDestinationPrefix ( String prefix ) { } public String getDestinationPrefix ( ) { } public UserQueueSuffixResolver getUserQueueSuffixResolver ( ) { } public MessageSendingOperations < String > getMessagingTemplate ( ) { } @ Override public void handleMessage ( Message < ? > message ) throws MessagingException { SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor . wrap ( message ) ; SimpMessageType messageType = headers . getMessageType ( ) ; String destination = headers . getDestination ( ) ; if ( ! ( MESSAGE . equals ( messageType ) ) ) { return ; } if ( ! ( checkDestination ( destination ) ) ) { return ; } if ( UserDestinationMessageHandler . logger . isTraceEnabled ( ) ) { UserDestinationMessageHandler . logger . trace ( ( "Processing<seq2seq4repair_space>message<seq2seq4repair_space>to<seq2seq4repair_space>destination<seq2seq4repair_space>" + destination ) ) ; } UserDestinationMessageHandler . UserDestinationParser destinationParser = new UserDestinationMessageHandler . UserDestinationParser ( destination ) ; String user = destinationParser . getUser ( ) ; if ( user == null ) { if ( UserDestinationMessageHandler . logger . isErrorEnabled ( ) ) { UserDestinationMessageHandler . logger . error ( ( ( ( "Ignoring<seq2seq4repair_space>message,<seq2seq4repair_space>expected<seq2seq4repair_space>destination<seq2seq4repair_space>pattern<seq2seq4repair_space>\"" + ( this . destinationPrefix ) ) + "{userId}//**\":<seq2seq4repair_space>" ) + destination ) ) ; } return ; } for ( String sessionId : this . userQueueSuffixResolver . getUserQueueSuffixes ( user ) ) { String targetDestination = destinationParser . getTargetDestination ( sessionId ) ; headers . setDestination ( targetDestination ) ; <START_BUG> message = MessageBuilder . withPayloadAndHeaders ( message . getPayload ( ) , headers ) . build ( ) ; <END_BUG> if ( UserDestinationMessageHandler . logger . isTraceEnabled ( ) ) { UserDestinationMessageHandler . logger . trace ( ( "Sending<seq2seq4repair_space>message<seq2seq4repair_space>to<seq2seq4repair_space>resolved<seq2seq4repair_space>target<seq2seq4repair_space>destination<seq2seq4repair_space>" + targetDestination ) ) ; } this . messagingTemplate . send ( targetDestination , message ) ; } } private boolean checkDestination ( String destination ) { } private class UserDestinationParser { private final String user ; private final String targetDestination ; public UserDestinationParser ( String destination ) { } public String getUser ( ) { } public String getTargetDestination ( String sessionId ) { } } }

Fix:
message = MessageBuilder . withPayload ( message . getPayload ( ) ) . setHeaders ( headers ) . build ( ) ;