Browse Source

Consistent fallback to NoUpgradeStrategyWebSocketService

Closes gh-33970

(cherry picked from commit 58c64cba2c)
6.1.x
Juergen Hoeller 1 year ago
parent
commit
3635ff0c17
  1. 12
      spring-webflux/src/main/java/org/springframework/web/reactive/config/WebFluxConfigurationSupport.java

12
spring-webflux/src/main/java/org/springframework/web/reactive/config/WebFluxConfigurationSupport.java

@ -478,9 +478,9 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
try { try {
service = new HandshakeWebSocketService(); service = new HandshakeWebSocketService();
} }
catch (IllegalStateException ex) { catch (Throwable ex) {
// Don't fail, test environment perhaps // Don't fail, test environment perhaps
service = new NoUpgradeStrategyWebSocketService(); service = new NoUpgradeStrategyWebSocketService(ex);
} }
} }
return service; return service;
@ -578,9 +578,15 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
private static final class NoUpgradeStrategyWebSocketService implements WebSocketService { private static final class NoUpgradeStrategyWebSocketService implements WebSocketService {
private final Throwable ex;
public NoUpgradeStrategyWebSocketService(Throwable ex) {
this.ex = ex;
}
@Override @Override
public Mono<Void> handleRequest(ServerWebExchange exchange, WebSocketHandler webSocketHandler) { 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));
} }
} }

Loading…
Cancel
Save