diff --git a/src/main/java/io/vertx/core/net/impl/TCPServerBase.java b/src/main/java/io/vertx/core/net/impl/TCPServerBase.java index 9ea90d086ec..95c6f131642 100644 --- a/src/main/java/io/vertx/core/net/impl/TCPServerBase.java +++ b/src/main/java/io/vertx/core/net/impl/TCPServerBase.java @@ -236,9 +236,8 @@ private synchronized Future listen(SocketAddress localAddress, ContextI // Server already exists with that host/port - we will use that actualServer = main; metrics = main.metrics; - sslChannelProvider = main.sslChannelProvider; childHandler = childHandler(listenContext, localAddress); - worker = ch -> childHandler.accept(ch, sslChannelProvider.result().sslChannelProvider()); + worker = ch -> childHandler.accept(ch, actualServer.sslChannelProvider.result().sslChannelProvider()); actualServer.servers.add(this); actualServer.channelBalancer.addWorker(eventLoop, worker); listenContext.addCloseHook(this); diff --git a/src/test/java/io/vertx/core/http/HttpTLSTest.java b/src/test/java/io/vertx/core/http/HttpTLSTest.java index b6ae2a7a85e..a9d3282ba71 100755 --- a/src/test/java/io/vertx/core/http/HttpTLSTest.java +++ b/src/test/java/io/vertx/core/http/HttpTLSTest.java @@ -34,6 +34,7 @@ import javax.net.ssl.*; +import io.vertx.core.*; import io.vertx.core.impl.VertxThread; import io.vertx.core.net.SSLOptions; import io.vertx.core.net.impl.KeyStoreHelper; @@ -43,9 +44,6 @@ import org.junit.rules.TemporaryFolder; import io.netty.util.internal.PlatformDependent; -import io.vertx.core.Future; -import io.vertx.core.Vertx; -import io.vertx.core.VertxOptions; import io.vertx.core.buffer.Buffer; import io.vertx.core.net.JdkSSLEngineOptions; import io.vertx.core.net.JksOptions; @@ -1641,11 +1639,38 @@ public void testHAProxy() throws Exception { @Test public void testUpdateSSLOptions() throws Exception { + testUpdateSSLOptions(false); + } + + @Test + public void testUpdateSSLOptionsWithScaledServer() throws Exception { + testUpdateSSLOptions(true); + } + + private void testUpdateSSLOptions(boolean scaled) throws Exception { server = createHttpServer(createBaseServerOptions().setSsl(true).setKeyCertOptions(Cert.SERVER_JKS.get())) .requestHandler(req -> { req.response().end("Hello World"); - }); + }); startServer(testAddress); + if (scaled) { + CountDownLatch latch = new CountDownLatch(1); + vertx.deployVerticle(new AbstractVerticle() { + private HttpServer server; + @Override + public void start(Promise startPromise) { + server = createHttpServer(createBaseServerOptions().setSsl(true).setKeyCertOptions(Cert.SERVER_JKS.get())) + .requestHandler(req -> { + req.response().end("Hello World"); + }); + server + .listen(testAddress) + .mapEmpty() + .onComplete(startPromise); + } + }).onComplete(onSuccess(v -> latch.countDown())); + awaitLatch(latch); + } Supplier> request = () -> client.request(requestOptions).compose(req -> req.send().compose(HttpClientResponse::body)); client = createHttpClient(new HttpClientOptions().setKeepAlive(false).setSsl(true).setTrustOptions(Trust.SERVER_JKS.get())); request.get().onComplete(onSuccess(body1 -> {