Skip to content

Commit

Permalink
Consistent fallback to NoUpgradeStrategyWebSocketService
Browse files Browse the repository at this point in the history
Closes gh-33970

(cherry picked from commit 58c64cb)
  • Loading branch information
jhoeller committed Dec 4, 2024
1 parent f20e76e commit 3635ff0
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,9 @@ private WebSocketService initWebSocketService() {
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;
Expand Down Expand Up @@ -578,9 +578,15 @@ public void validate(@Nullable Object target, Errors errors) {

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));
}
}

Expand Down

0 comments on commit 3635ff0

Please sign in to comment.