Skip to content

Commit c643bfe

Browse files
committed
make DefaultHandshakeHandler a bean (#1844)
if it is not a bean, DefaultHandshakeHandler.setServletContext is not called. DefaultHandshakeHandler delegates the call to RequestUpgradeStrategy.setServletContext. JettyRequestUpgradeStrategy's setServletContext calls the webSocketConfigurer. this call was missing in the chain. we need it to be called since webSocketConfigurer contains config for extended idle timeout.
1 parent 8b482fd commit c643bfe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/de/rwth/idsg/steve/config/WebSocketConfiguration.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import lombok.RequiredArgsConstructor;
2929
import lombok.extern.slf4j.Slf4j;
3030
import org.eclipse.jetty.websocket.core.WebSocketConstants;
31+
import org.springframework.context.annotation.Bean;
3132
import org.springframework.context.annotation.Configuration;
3233
import org.springframework.web.socket.config.annotation.EnableWebSocket;
3334
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
@@ -62,7 +63,7 @@ public class WebSocketConfiguration implements WebSocketConfigurer {
6263
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
6364
OcppWebSocketHandshakeHandler handshakeHandler = new OcppWebSocketHandshakeHandler(
6465
chargeBoxIdValidator,
65-
defaultHandshakeHandler(),
66+
handshakeHandler(),
6667
Lists.newArrayList(ocpp16WebSocketEndpoint, ocpp15WebSocketEndpoint, ocpp12WebSocketEndpoint),
6768
chargePointRegistrationService
6869
);
@@ -77,7 +78,8 @@ public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
7778
*
7879
* Otherwise, defaults come from {@link WebSocketConstants}
7980
*/
80-
private static DefaultHandshakeHandler defaultHandshakeHandler() {
81+
@Bean
82+
public DefaultHandshakeHandler handshakeHandler() {
8183
JettyRequestUpgradeStrategy strategy = new JettyRequestUpgradeStrategy();
8284

8385
strategy.addWebSocketConfigurer(configurable -> {

0 commit comments

Comments
 (0)