Skip to content

Commit

Permalink
Get rid of a lambda in Vertx runtime code
Browse files Browse the repository at this point in the history
(cherry picked from commit 5b0ef48)
  • Loading branch information
geoand authored and gsmet committed May 16, 2022
1 parent 92a91d0 commit b52cf38
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1157,60 +1157,63 @@ public void handle(Void event) {
}
});
}
httpServer.listen(options.getPort(), options.getHost(), event -> {
if (event.cause() != null) {
startFuture.fail(event.cause());
} else {
// Port may be random, so set the actual port
int actualPort = event.result().actualPort();

if (https) {
actualHttpsPort = actualPort;
httpServer.listen(options.getPort(), options.getHost(), new Handler<>() {
@Override
public void handle(AsyncResult<HttpServer> event) {
if (event.cause() != null) {
startFuture.fail(event.cause());
} else {
actualHttpPort = actualPort;
}
if (remainingCount.decrementAndGet() == 0) {
//make sure we only set the properties once
if (actualPort != options.getPort()) {
// Override quarkus.http(s)?.(test-)?port
String schema;
if (https) {
clearHttpsProperty = true;
schema = "https";
} else {
clearHttpProperty = true;
actualHttpPort = actualPort;
schema = "http";
}
portPropertiesToRestore = new HashMap<>();
String portPropertyValue = String.valueOf(actualPort);
//we always set the .port property, even if we are in test mode, so this will always
//reflect the current port
String portPropertyName = "quarkus." + schema + ".port";
String prevPortPropertyValue = System.setProperty(portPropertyName, portPropertyValue);
if (!Objects.equals(prevPortPropertyValue, portPropertyValue)) {
portPropertiesToRestore.put(portPropertyName, prevPortPropertyValue);
}
if (launchMode == LaunchMode.TEST) {
//we also set the test-port property in a test
String testPropName = "quarkus." + schema + ".test-port";
String prevTestPropPrevValue = System.setProperty(testPropName, portPropertyValue);
if (!Objects.equals(prevTestPropPrevValue, portPropertyValue)) {
portPropertiesToRestore.put(testPropName, prevTestPropPrevValue);
// Port may be random, so set the actual port
int actualPort = event.result().actualPort();

if (https) {
actualHttpsPort = actualPort;
} else {
actualHttpPort = actualPort;
}
if (remainingCount.decrementAndGet() == 0) {
//make sure we only set the properties once
if (actualPort != options.getPort()) {
// Override quarkus.http(s)?.(test-)?port
String schema;
if (https) {
clearHttpsProperty = true;
schema = "https";
} else {
clearHttpProperty = true;
actualHttpPort = actualPort;
schema = "http";
}
}
if (launchMode.isDevOrTest()) {
// set the profile property as well to make sure we don't have any inconsistencies
portPropertyName = propertyWithProfilePrefix(portPropertyName);
prevPortPropertyValue = System.setProperty(portPropertyName, portPropertyValue);
portPropertiesToRestore = new HashMap<>();
String portPropertyValue = String.valueOf(actualPort);
//we always set the .port property, even if we are in test mode, so this will always
//reflect the current port
String portPropertyName = "quarkus." + schema + ".port";
String prevPortPropertyValue = System.setProperty(portPropertyName, portPropertyValue);
if (!Objects.equals(prevPortPropertyValue, portPropertyValue)) {
portPropertiesToRestore.put(portPropertyName, prevPortPropertyValue);
}
if (launchMode == LaunchMode.TEST) {
//we also set the test-port property in a test
String testPropName = "quarkus." + schema + ".test-port";
String prevTestPropPrevValue = System.setProperty(testPropName, portPropertyValue);
if (!Objects.equals(prevTestPropPrevValue, portPropertyValue)) {
portPropertiesToRestore.put(testPropName, prevTestPropPrevValue);
}
}
if (launchMode.isDevOrTest()) {
// set the profile property as well to make sure we don't have any inconsistencies
portPropertyName = propertyWithProfilePrefix(portPropertyName);
prevPortPropertyValue = System.setProperty(portPropertyName, portPropertyValue);
if (!Objects.equals(prevPortPropertyValue, portPropertyValue)) {
portPropertiesToRestore.put(portPropertyName, prevPortPropertyValue);
}
}
}
startFuture.complete(null);
}
startFuture.complete(null);
}

}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ private static void initializeClusterOptions(VertxConfiguration conf, VertxOptio
if (cluster.port.isPresent()) {
options.getEventBusOptions().setPort(cluster.port.getAsInt());
}
cluster.publicHost.ifPresent(options.getEventBusOptions()::setClusterPublicHost);
if (cluster.publicHost.isPresent()) {
options.getEventBusOptions().setClusterPublicHost(cluster.publicHost.get());
}
if (cluster.publicPort.isPresent()) {
options.getEventBusOptions().setPort(cluster.publicPort.getAsInt());
}
Expand Down

0 comments on commit b52cf38

Please sign in to comment.