Skip to content

Commit f6d9350

Browse files
artembilanspring-builds
authored andcommitted
Fix ServerWebSocketContainer for optional handshakeHandler
The `HandshakeHandler` is really optional in the `WebSocketHandlerRegistration`. So, check `if (this.handshakeHandler != null)` before calling `registration.setHandshakeHandler()` (cherry picked from commit ec8e1b1)
1 parent 523d1d0 commit f6d9350

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

spring-integration-websocket/src/main/java/org/springframework/integration/websocket/ServerWebSocketContainer.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,16 @@ public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
162162
}
163163
}
164164

165-
Assert.notNull(this.handshakeHandler, "'handshakeHandler' must not be null");
166-
WebSocketHandlerRegistration registration = registry.addHandler(webSocketHandler, this.paths)
167-
.setHandshakeHandler(this.handshakeHandler);
165+
WebSocketHandlerRegistration registration =
166+
registry.addHandler(webSocketHandler, this.paths)
167+
.addInterceptors(this.interceptors)
168+
.setAllowedOrigins(this.origins);
168169

169-
configureRegistration(registration);
170-
configureSockJsOptionsIfAny(registration);
171-
}
170+
if (this.handshakeHandler != null) {
171+
registration.setHandshakeHandler(this.handshakeHandler);
172+
}
172173

173-
private void configureRegistration(WebSocketHandlerRegistration registration) {
174-
registration.addInterceptors(this.interceptors);
175-
registration.setAllowedOrigins(this.origins);
174+
configureSockJsOptionsIfAny(registration);
176175
}
177176

178177
private void configureSockJsOptionsIfAny(WebSocketHandlerRegistration registration) {

0 commit comments

Comments
 (0)