Fix SubProtocolHandler duplicate registration

Prior to this change, duplicate SubProtocolHandlers could be registered
when configuring STOMP with several registrations:

    public void registerStompEndpoints
          (final StompEndpointRegistry registry) {
      this.endpointRegistry.addEndpoint("/stompOverWebSocket");
      this.endpointRegistry.addEndpoint("/stompOverSockJS").withSockJS();
    }

This commit registers sub-protocols in a Set instead of a list (see
SubProtocolWebSocketHandler), thus fixing the issue.

Issue: SPR-12403
This commit is contained in:
Brian Clozel
2014-11-03 14:25:27 +01:00
parent 330897b411
commit 1fff631daa
2 changed files with 8 additions and 3 deletions

View File

@@ -84,6 +84,9 @@ public class WebMvcStompEndpointRegistryTests {
this.endpointRegistry.addEndpoint("/stompOverWebSocket");
this.endpointRegistry.addEndpoint("/stompOverSockJS").withSockJS();
//SPR-12403
assertEquals(1, this.webSocketHandler.getProtocolHandlers().size());
hm = (SimpleUrlHandlerMapping) this.endpointRegistry.getHandlerMapping();
assertEquals(2, hm.getUrlMap().size());
assertNotNull(hm.getUrlMap().get("/stompOverWebSocket"));