Refactor Undertow WebSocket client configuration model

This commit removes the statically created XnioWorker which is an
"active" component and should not be created automatically and could
lead to resource leaks. Instead XnioWorker is now required at
construction aligning better with WebSocketClient#connectionBuilder
which also does not have a "default" worker option.

Since the XnioWorker is the main input for creating a ConnectionBuilder
we now create the ConnectionBuider in a protected method and then allow
a Consumer<ConnectionBuilder> to configure it further as opposed to the
Function<URI, ConnectionBuilder> used previously.

This commit also removes default SSL context initialization for RxNetty
to better align with other client implementations.

Issue: SPR-14527
This commit is contained in:
Rossen Stoyanchev
2016-12-27 15:45:10 -05:00
parent 384e851bd1
commit e4d39bb86f
3 changed files with 96 additions and 86 deletions

View File

@@ -16,6 +16,7 @@
package org.springframework.web.reactive.socket;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -27,6 +28,8 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import org.xnio.OptionMap;
import org.xnio.Xnio;
import reactor.core.publisher.Flux;
import reactor.util.function.Tuple3;
@@ -72,6 +75,9 @@ import static org.junit.Assume.assumeFalse;
@SuppressWarnings({"unused", "WeakerAccess"})
public abstract class AbstractWebSocketIntegrationTests {
private static final File TMP_DIR = new File(System.getProperty("java.io.tmpdir"));
protected int port;
@Parameter(0)
@@ -85,19 +91,17 @@ public abstract class AbstractWebSocketIntegrationTests {
@Parameters(name = "client[{0}] - server [{1}]")
public static Object[][] arguments() {
File base = new File(System.getProperty("java.io.tmpdir"));
public static Object[][] arguments() throws IOException {
Flux<? extends WebSocketClient> clients = Flux.concat(
Flux.just(new StandardWebSocketClient()).repeat(5),
Flux.just(new JettyWebSocketClient()).repeat(5),
Flux.just(new ReactorNettyWebSocketClient()).repeat(5),
Flux.just(new RxNettyWebSocketClient()).repeat(5),
Flux.just(new UndertowWebSocketClient()).repeat(5));
Flux.just(new UndertowWebSocketClient(Xnio.getInstance().createWorker(OptionMap.EMPTY))).repeat(5));
Flux<? extends HttpServer> servers = Flux.just(
new TomcatHttpServer(base.getAbsolutePath(), WsContextListener.class),
new TomcatHttpServer(TMP_DIR.getAbsolutePath(), WsContextListener.class),
new JettyHttpServer(),
new ReactorHttpServer(),
new RxNettyHttpServer(),