diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java index e7e3bec93318f..97ede948aecaf 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java @@ -41,6 +41,7 @@ import org.wildfly.common.cpu.ProcessorInfo; import io.netty.bootstrap.ServerBootstrap; +import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelInitializer; import io.netty.handler.codec.http.HttpHeaderNames; import io.netty.handler.codec.http.HttpResponseStatus; @@ -263,7 +264,16 @@ public void startServer(Supplier vertx, ShutdownContext shutdown, if (startVirtual) { initializeVirtual(vertx.get()); - shutdown.addShutdownTask(() -> virtualBootstrap = null); + shutdown.addShutdownTask(() -> { + try { + virtualBootstrapChannel.channel().close().sync(); + } catch (InterruptedException e) { + LOGGER.warn("Unable to close virtualBootstrapChannel"); + } finally { + virtualBootstrapChannel = null; + virtualBootstrap = null; + } + }); } HttpConfiguration httpConfiguration = this.httpConfiguration.getValue(); if (startSocket && (httpConfiguration.hostEnabled || httpConfiguration.domainSocketEnabled)) { @@ -1187,6 +1197,7 @@ private String propertyWithProfilePrefix(String portPropertyName) { } protected static ServerBootstrap virtualBootstrap; + protected static ChannelFuture virtualBootstrapChannel; public static VirtualAddress VIRTUAL_HTTP = new VirtualAddress("netty-virtual-http"); private static void initializeVirtual(Vertx vertxRuntime) { @@ -1233,7 +1244,7 @@ public void initChannel(VirtualChannel ch) throws Exception { // Start the server. try { - virtualBootstrap.bind(VIRTUAL_HTTP).sync(); + virtualBootstrapChannel = virtualBootstrap.bind(VIRTUAL_HTTP).sync(); } catch (InterruptedException e) { throw new RuntimeException("failed to bind virtual http"); }