diff --git a/spring-web/src/main/java/org/springframework/web/cors/reactive/CorsProcessor.java b/spring-web/src/main/java/org/springframework/web/cors/reactive/CorsProcessor.java index bc892836f8..0b6d4dc7a1 100644 --- a/spring-web/src/main/java/org/springframework/web/cors/reactive/CorsProcessor.java +++ b/spring-web/src/main/java/org/springframework/web/cors/reactive/CorsProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 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. @@ -16,20 +16,14 @@ package org.springframework.web.cors.reactive; -import reactor.core.publisher.Mono; - import org.springframework.lang.Nullable; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.server.ServerWebExchange; /** - * A strategy that takes a reactive HTTP exchange and a {@link CorsConfiguration} and - * updates the response. - * - *

This component is not concerned with how a {@code CorsConfiguration} is - * selected but rather takes follow-up actions such as applying CORS validation - * checks and either rejecting the response or adding CORS headers to the - * response. + * A strategy to apply CORS validation checks and updates to a + * {@link ServerWebExchange}, either rejecting through the response or adding + * CORS related headers, based on a pre-selected {@link CorsConfiguration}. * * @author Sebastien Deleuze * @author Rossen Stoyanchev @@ -39,10 +33,11 @@ import org.springframework.web.server.ServerWebExchange; public interface CorsProcessor { /** - * Process an HTTP exchange given a {@code CorsConfiguration}. - * @param configuration the applicable CORS configuration (possibly {@code null}) - * @param exchange the current HTTP request / response - * @return a {@link Mono} emitting {@code false} if the request is rejected, {@code true} otherwise + * Process a request using the given {@code CorsConfiguration}. + * @param configuration the CORS configuration to use; possibly {@code null} + * in which case pre-flight requests are rejected, but all others allowed. + * @param exchange the current exchange + * @return {@code false} if the request was rejected, {@code true} otherwise */ boolean process(@Nullable CorsConfiguration configuration, ServerWebExchange exchange); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/TomcatWebSocketClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/TomcatWebSocketClient.java index cd46976324..56f292b3e8 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/TomcatWebSocketClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/TomcatWebSocketClient.java @@ -23,6 +23,7 @@ import org.springframework.web.reactive.socket.HandshakeInfo; import org.springframework.web.reactive.socket.adapter.StandardWebSocketSession; import org.springframework.web.reactive.socket.adapter.TomcatWebSocketSession; +import org.apache.tomcat.websocket.WsWebSocketContainer; import reactor.core.publisher.MonoProcessor; /** @@ -35,6 +36,7 @@ public class TomcatWebSocketClient extends StandardWebSocketClient { public TomcatWebSocketClient() { + this(new WsWebSocketContainer()); } public TomcatWebSocketClient(WebSocketContainer webSocketContainer) { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/RequestUpgradeStrategy.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/RequestUpgradeStrategy.java index 16f57c3eff..568877faae 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/RequestUpgradeStrategy.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/RequestUpgradeStrategy.java @@ -46,6 +46,7 @@ public interface RequestUpgradeStrategy { * @return completion {@code Mono} to indicate the outcome of the * WebSocket session handling. */ - Mono upgrade(ServerWebExchange exchange, WebSocketHandler webSocketHandler, @Nullable String subProtocol); + Mono upgrade(ServerWebExchange exchange, WebSocketHandler webSocketHandler, + @Nullable String subProtocol); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractWebSocketIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractWebSocketIntegrationTests.java index fd643df932..a97f048e02 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractWebSocketIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractWebSocketIntegrationTests.java @@ -92,7 +92,7 @@ public abstract class AbstractWebSocketIntegrationTests { public static Object[][] arguments() throws IOException { WebSocketClient[] clients = new WebSocketClient[] { - new TomcatWebSocketClient(new WsWebSocketContainer()), + new TomcatWebSocketClient(), new JettyWebSocketClient(), new ReactorNettyWebSocketClient(), new UndertowWebSocketClient(Xnio.getInstance().createWorker(OptionMap.EMPTY))