Skip to content

Commit

Permalink
Drop server-specific TomcatRequestUpgradeStrategy for WebFlux
Browse files Browse the repository at this point in the history
StandardWebSocketUpgradeStrategy is the common replacement on Tomcat.

See spring-projectsgh-33744
  • Loading branch information
jhoeller committed Dec 4, 2024
1 parent 162e533 commit da75840
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -48,7 +48,6 @@
import org.springframework.web.reactive.socket.server.upgrade.ReactorNetty2RequestUpgradeStrategy;
import org.springframework.web.reactive.socket.server.upgrade.ReactorNettyRequestUpgradeStrategy;
import org.springframework.web.reactive.socket.server.upgrade.StandardWebSocketUpgradeStrategy;
import org.springframework.web.reactive.socket.server.upgrade.TomcatRequestUpgradeStrategy;
import org.springframework.web.reactive.socket.server.upgrade.UndertowRequestUpgradeStrategy;
import org.springframework.web.server.MethodNotAllowedException;
import org.springframework.web.server.ServerWebExchange;
Expand All @@ -73,8 +72,6 @@ public class HandshakeWebSocketService implements WebSocketService, Lifecycle {
private static final Mono<Map<String, Object>> EMPTY_ATTRIBUTES = Mono.just(Collections.emptyMap());


private static final boolean tomcatWsPresent;

private static final boolean jettyWsPresent;

private static final boolean jettyCoreWsPresent;
Expand All @@ -87,8 +84,6 @@ public class HandshakeWebSocketService implements WebSocketService, Lifecycle {

static {
ClassLoader classLoader = HandshakeWebSocketService.class.getClassLoader();
tomcatWsPresent = ClassUtils.isPresent(
"org.apache.tomcat.websocket.server.WsHttpUpgradeHandler", classLoader);
jettyWsPresent = ClassUtils.isPresent(
"org.eclipse.jetty.ee10.websocket.server.JettyWebSocketServerContainer", classLoader);
jettyCoreWsPresent = ClassUtils.isPresent(
Expand Down Expand Up @@ -277,10 +272,7 @@ private HandshakeInfo createHandshakeInfo(ServerWebExchange exchange, ServerHttp


static RequestUpgradeStrategy initUpgradeStrategy() {
if (tomcatWsPresent) {
return new TomcatRequestUpgradeStrategy();
}
else if (jettyWsPresent) {
if (jettyWsPresent) {
return new JettyRequestUpgradeStrategy();
}
else if (jettyCoreWsPresent) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
import org.springframework.web.reactive.socket.server.upgrade.JettyRequestUpgradeStrategy;
import org.springframework.web.reactive.socket.server.upgrade.ReactorNetty2RequestUpgradeStrategy;
import org.springframework.web.reactive.socket.server.upgrade.ReactorNettyRequestUpgradeStrategy;
import org.springframework.web.reactive.socket.server.upgrade.TomcatRequestUpgradeStrategy;
import org.springframework.web.reactive.socket.server.upgrade.StandardWebSocketUpgradeStrategy;
import org.springframework.web.reactive.socket.server.upgrade.UndertowRequestUpgradeStrategy;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
Expand Down Expand Up @@ -205,58 +205,62 @@ public WebSocketService webSocketService() {


@Configuration
static class ReactorNettyConfig extends AbstractHandlerAdapterConfig {
static class TomcatConfig extends AbstractHandlerAdapterConfig {

@Override
protected RequestUpgradeStrategy getUpgradeStrategy() {
return new ReactorNettyRequestUpgradeStrategy();
return new StandardWebSocketUpgradeStrategy();
}
}


@Configuration
static class ReactorNetty2Config extends AbstractHandlerAdapterConfig {
static class JettyConfig extends AbstractHandlerAdapterConfig {

@Override
protected RequestUpgradeStrategy getUpgradeStrategy() {
return new ReactorNetty2RequestUpgradeStrategy();
return new JettyRequestUpgradeStrategy();
}
}


@Configuration
static class TomcatConfig extends AbstractHandlerAdapterConfig {
static class JettyCoreConfig extends AbstractHandlerAdapterConfig {

@Override
protected RequestUpgradeStrategy getUpgradeStrategy() {
return new TomcatRequestUpgradeStrategy();
return new JettyCoreRequestUpgradeStrategy();
}
}


@Configuration
static class UndertowConfig extends AbstractHandlerAdapterConfig {
static class ReactorNettyConfig extends AbstractHandlerAdapterConfig {

@Override
protected RequestUpgradeStrategy getUpgradeStrategy() {
return new UndertowRequestUpgradeStrategy();
return new ReactorNettyRequestUpgradeStrategy();
}
}


@Configuration
static class JettyConfig extends AbstractHandlerAdapterConfig {
static class ReactorNetty2Config extends AbstractHandlerAdapterConfig {

@Override
protected RequestUpgradeStrategy getUpgradeStrategy() {
return new JettyRequestUpgradeStrategy();
return new ReactorNetty2RequestUpgradeStrategy();
}
}


@Configuration
static class JettyCoreConfig extends AbstractHandlerAdapterConfig {
static class UndertowConfig extends AbstractHandlerAdapterConfig {

@Override
protected RequestUpgradeStrategy getUpgradeStrategy() {
return new JettyCoreRequestUpgradeStrategy();
return new UndertowRequestUpgradeStrategy();
}
}

}

0 comments on commit da75840

Please sign in to comment.