-
Notifications
You must be signed in to change notification settings - Fork 38.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SimpMessagingTemplate.convertAndSend results in UnsupportedOperationException when Spring Cloud Sleuth is present #25821
Comments
There seems to be some internal state mismatch: Despite still being in mutable state (passing that assertion in |
Is there any way to solve the problem?@jhoeller @rstoyanchev Now I have to delete the sleuth reference to use spring websocket. |
@rogue2yjg does this fail predictably every time? If you have something to reproduce with that we can debug that would be really helpful. |
Yes, it fails every time, not surprisingly. The attach is my application to reproduce that, hoping that will be helpful. |
Thanks for the sample, I was able to debug and find the issue in I will work on a fix. In the mean time as a workaround you could install an interceptor on the clientOutboundChannel that makes the native headers modifiable: @Override
public void configureClientOutboundChannel(ChannelRegistration registration) {
// Workaround for https://github.com/spring-projects/spring-framework/issues/25821
registration.interceptors(new ChannelInterceptor() {
@Override
public Message<?> preSend(Message<?> message, MessageChannel channel) {
MessageHeaderAccessor accessor = MessageHeaderAccessor.getMutableAccessor(message);
accessor.setLeaveMutable(true);
String key = NativeMessageHeaderAccessor.NATIVE_HEADERS;
Map<String, List<String>> map = (Map<String, List<String>>) accessor.getHeader(key);
if (map != null) {
accessor.removeHeader(key);
accessor.setHeader(key, new LinkedMultiValueMap<>(map));
}
return new GenericMessage<>(message.getPayload(), accessor.toMessageHeaders());
}
});
} |
springboot version: 2.1.3
spring-websocket version: 5.1.1
spring-cloud-sleuth version: 2.1.1
When I try to use SimpMessagingTemplate.convertAndSend to send a String message to the websocket client after adding spring cloud sleuth to the application, an exception occurs:
some primary code belows:
The text was updated successfully, but these errors were encountered: