Sergi Almar opened SPR-13469 and commented
STOMP endpoint / WebSocketHandler registration doesn't fail if there's already a mapping on the same path (when not using SockJS). As an example, the following configuration won't fail but will prevent the WebSocket handshake to succeed (as the MVC endpoint will be called during handshake):
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(new MyHandler(), "/path");
}
}
@Controller
public class MyController {
@RequestMapping("/path")
public void handle() {
...
}
}
No further details from SPR-13469
Comment From: spring-projects-issues
Rossen Stoyanchev commented
These are different HandlerMapping's, so we can't, and arguably shouldn't, reject them. It's all based on the order property which should be considered first. This is no different than a potential overlap between annotated controllers and static resource URLs.
By default annotated controllers are at 0, and STOMP endpoints are at 1. In retrospect, a default order of -1 for STOMP endpoints might have made more sense but all in all. That said it is possible to change the order for STOMP endpoints via StompEndpointRegistry so all in all I'm in favor of resolving this as "Works as designed".