WebSocketMessageBrokerStats has null stats for stompSubProtocolHandler since 5.3.2 #26536
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Since upgrading spring-websockets library to version 5.3.2 I've noticed the
WebSocketMessageBrokerStats
class no longer provides metrics forstompSubProtocolHandler
. I think I've traced it down to different bean creation order between two library versions, in which thewebSocketMessageBrokerStats
bean is constructed before thestompWebSocketHandlerMapping
which adds astompSubProtocolHandler
from adding a stomp endpoint.A quick summary of the difference:
Broken since Spring Boot 2.4.1 with websocket 5.3.2
Here's the call order I'm seeing in the new version:
WebSocketMessageBrokerConfigurationSupport#subProtocolWebSocketHandler
WebSocketMessageBrokerConfigurationSupport#webSocketMessageBrokerStats
subProtocolWebSocketHandler
bean at this stage has noprotocolHandlers
and nodefaultProtocolHandler
WebSocketMessageBrokerStats#setSubProtocolWebSocketHandler
setsstompSubProtocolHandler
to nullWebSocketMessageBrokerConfigurationSupport#stompWebSocketHandlerMapping
WebSocketMessageBrokerConfigurationSupport#registerStompEndpoints
registry.addEndpoint(...)
adds oneprotocolHandler
towebSocketHandler
WebSocketMessageBrokerStats#getStompSubProtocolStatsInfo
"null"
string is returned.Was working in Spring Boot 2.4.0 with websocket 5.3.1
Call chain for the 'working' version where
webSocketMessageBrokerStats.stompSubProtocolStatsInfo
doesn't return null.WebSocketMessageBrokerConfigurationSupport#subProtocolWebSocketHandler
WebSocketMessageBrokerConfigurationSupport#stompWebSocketHandlerMapping
WebSocketMessageBrokerConfigurationSupport#registerStompEndpoints
registry.addEndpoint(...)
adds oneprotocolHandler
towebSocketHandler
WebSocketMessageBrokerConfigurationSupport#webSocketMessageBrokerStats
subProtocolWebSocketHandler
bean at this stage has oneprotocolHandlers
and nodefaultProtocolHandler
WebSocketMessageBrokerStats#getStompSubProtocolStatsInfo
processed CONNECT(0)-CONNECTED(0)-DISCONNECT(0)
string is returned, which is expected.I also created a demo app for the issue here https://github.com/countableSet/spring-websocket-metrics-bug-demo
Just flip between spring boot versions
2.4.0
and2.4.1
you should be able to see the issue in std.out.The text was updated successfully, but these errors were encountered: