Skip to content

Commit

Permalink
Consistent fallback to NoUpgradeStrategyWebSocketService
Browse files Browse the repository at this point in the history
Closes gh-33970
  • Loading branch information
jhoeller committed Dec 4, 2024
1 parent 3074116 commit 58c64cb
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,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 @@ -608,9 +608,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 58c64cb

Please sign in to comment.