Consistent fallback to NoUpgradeStrategyWebSocketService

Closes gh-33970
This commit is contained in:
Juergen Hoeller
2024-12-04 16:39:41 +01:00
parent 307411631d
commit 58c64cba2c

View File

@@ -485,9 +485,9 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
try {
service = new HandshakeWebSocketService();
}
catch (IllegalStateException ex) {
catch (Throwable ex) {
// Don't fail, test environment perhaps
service = new NoUpgradeStrategyWebSocketService();
service = new NoUpgradeStrategyWebSocketService(ex);
}
}
return service;
@@ -608,9 +608,15 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
private static final class NoUpgradeStrategyWebSocketService implements WebSocketService {
private final Throwable ex;
public NoUpgradeStrategyWebSocketService(Throwable ex) {
this.ex = ex;
}
@Override
public Mono<Void> handleRequest(ServerWebExchange exchange, WebSocketHandler webSocketHandler) {
return Mono.error(new IllegalStateException("No suitable RequestUpgradeStrategy"));
return Mono.error(new IllegalStateException("No suitable RequestUpgradeStrategy", this.ex));
}
}