Skip to content

Commit

Permalink
Merge pull request #12401 from cescoffier/fix-port0
Browse files Browse the repository at this point in the history
Fix the handling of the port 0
  • Loading branch information
stuartwdouglas committed Sep 29, 2020
2 parents ac0e934 + 70fa17d commit 4216d7a
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ public class VertxHttpRecorder {

private static volatile Handler<HttpServerRequest> rootHandler;

private static volatile int actualHttpPort = -1;
private static volatile int actualHttpsPort = -1;

private static final Handler<HttpServerRequest> ACTUAL_ROOT = new Handler<HttpServerRequest>() {
@Override
public void handle(HttpServerRequest httpServerRequest) {
Expand Down Expand Up @@ -509,15 +512,15 @@ private static void setHttpServerTiming(InsecureRequests insecureRequests, HttpS

if (httpServerOptions != null && !InsecureRequests.DISABLED.equals(insecureRequests)) {
serverListeningMessage += String.format(
"http://%s:%s", httpServerOptions.getHost(), httpServerOptions.getPort());
"http://%s:%s", httpServerOptions.getHost(), actualHttpPort);
socketCount++;
}

if (sslConfig != null) {
if (socketCount > 0) {
serverListeningMessage += " and ";
}
serverListeningMessage += String.format("https://%s:%s", sslConfig.getHost(), sslConfig.getPort());
serverListeningMessage += String.format("https://%s:%s", sslConfig.getHost(), actualHttpsPort);
socketCount++;
}

Expand Down Expand Up @@ -892,6 +895,7 @@ private void setupTcpHttpServer(HttpServer httpServer, HttpServerOptions options
schema = "https";
} else {
clearHttpProperty = true;
actualHttpPort = actualPort;
schema = "http";
}
portPropertiesToRestore = new HashMap<>();
Expand All @@ -910,12 +914,16 @@ private void setupTcpHttpServer(HttpServer httpServer, HttpServerOptions options
portPropertiesToRestore.put(portPropertyName, prevPortPropertyValue);
}
}
// Set in HttpOptions to output the port in the Timing class
options.setPort(actualPort);
}
if (https) {
actualHttpsPort = actualPort;
} else {
actualHttpPort = actualPort;
}
if (remainingCount.decrementAndGet() == 0) {
startFuture.complete(null);
}

}
});
}
Expand Down

0 comments on commit 4216d7a

Please sign in to comment.