fix(tls): fail startup when public listener cannot bind (#3362)

This commit is contained in:
Niels Kootstra authored and GitHub committed 2026-09-10 14:08:20 -04:00
1 parent c99ecea0da
commit 2fd55b53df
2 files changed
+33 -5

No files matched your search

@@ -17,6 +17,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CompletionException;
/**
* A TCP proxy server that enables HTTP and HTTPS on the same port (LocalStack parity).
@@ -109,7 +110,8 @@ public class TlsProxyServer {
NetServer server = vertx.createNetServer(options);
server.connectHandler(connectHandler);
proxyServers.add(server);
server.listen().onComplete(ar -> {
var bind = server.listen();
bind.onComplete(ar -> {
if (ar.succeeded()) {
failedPorts.remove(port);
LOG.infov("TLS proxy: listening on port {0} (HTTP→{1}, HTTPS→{2})",
@@ -128,6 +130,16 @@ public class TlsProxyServer {
String.valueOf(port), ar.cause().getMessage());
}
});
if (port == config.port()) {
try {
bind.toCompletionStage().toCompletableFuture().join();
} catch (CompletionException e) {
stop();
Throwable cause = e.getCause() != null ? e.getCause() : e;
throw new IllegalStateException(
"TLS proxy failed to bind public port " + port, cause);
}
}
}
}