From 9b53b86d24330c2974cde3b4fb141e8362dac369 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 24 May 2017 15:05:59 -0400 Subject: [PATCH] Check Reactor presence after Undertow for WebSocket Issue: SPR-15539 --- .../server/support/HandshakeWebSocketService.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketService.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketService.java index c9c39e3d0f..a7ab423019 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketService.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketService.java @@ -62,14 +62,14 @@ public class HandshakeWebSocketService implements WebSocketService, Lifecycle { "org.eclipse.jetty.websocket.server.WebSocketServerFactory", HandshakeWebSocketService.class.getClassLoader()); - private static final boolean reactorNettyPresent = ClassUtils.isPresent( - "reactor.ipc.netty.http.server.HttpServerResponse", - HandshakeWebSocketService.class.getClassLoader()); - private static final boolean undertowPresent = ClassUtils.isPresent( "io.undertow.websockets.WebSocketProtocolHandshakeHandler", HandshakeWebSocketService.class.getClassLoader()); + private static final boolean reactorNettyPresent = ClassUtils.isPresent( + "reactor.ipc.netty.http.server.HttpServerResponse", + HandshakeWebSocketService.class.getClassLoader()); + protected static final Log logger = LogFactory.getLog(HandshakeWebSocketService.class); @@ -104,12 +104,13 @@ public class HandshakeWebSocketService implements WebSocketService, Lifecycle { else if (jettyPresent) { className = "JettyRequestUpgradeStrategy"; } - else if (reactorNettyPresent) { - className = "ReactorNettyRequestUpgradeStrategy"; - } else if (undertowPresent) { className = "UndertowRequestUpgradeStrategy"; } + else if (reactorNettyPresent) { + // As late as possible (Reactor Netty commonly used for WebClient) + className = "ReactorNettyRequestUpgradeStrategy"; + } else { throw new IllegalStateException("No suitable default RequestUpgradeStrategy found"); }