Skip to content

Commit

Permalink
Pulls System.clearProperty from stuartwdouglas:graceful-shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Karm committed Feb 18, 2020
1 parent 7662597 commit 7446beb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ private static class WebDeploymentVerticle extends AbstractVerticle {
private final HttpServerOptions httpOptions;
private final HttpServerOptions httpsOptions;
private final LaunchMode launchMode;
private volatile boolean clearHttpProperty = false;
private volatile boolean clearHttpsProperty = false;

public WebDeploymentVerticle(int port, int httpsPort, String host, HttpServerOptions httpOptions,
HttpServerOptions httpsOptions, LaunchMode launchMode) {
Expand All @@ -588,6 +590,7 @@ public void start(Future<Void> startFuture) {
int actualPort = event.result().actualPort();
if (actualPort != port) {
// Override quarkus.http.(test-)?port
clearHttpProperty = true;
System.setProperty(launchMode == LaunchMode.TEST ? "quarkus.http.test-port" : "quarkus.http.port",
String.valueOf(actualPort));
// Set in HttpOptions to output the port in the Timing class
Expand All @@ -608,6 +611,7 @@ public void start(Future<Void> startFuture) {
int actualPort = event.result().actualPort();
if (actualPort != httpsPort) {
// Override quarkus.https.(test-)?port
clearHttpsProperty = true;
System.setProperty(launchMode == LaunchMode.TEST ? "quarkus.https.test-port" : "quarkus.https.port",
String.valueOf(actualPort));
// Set in HttpOptions to output the port in the Timing class
Expand All @@ -623,6 +627,12 @@ public void start(Future<Void> startFuture) {

@Override
public void stop(Future<Void> stopFuture) {
if (clearHttpProperty) {
System.clearProperty(launchMode == LaunchMode.TEST ? "quarkus.http.test-port" : "quarkus.http.port");
}
if (clearHttpsProperty) {
System.clearProperty(launchMode == LaunchMode.TEST ? "quarkus.https.test-port" : "quarkus.https.port");
}
httpServer.close(new Handler<AsyncResult<Void>>() {
@Override
public void handle(AsyncResult<Void> event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ public void afterAll(ExtensionContext extensionContext) throws Exception {
}
curatedApplication.close();
} finally {
System.clearProperty("test.url");
Thread.currentThread().setContextClassLoader(originalClassLoader);
timeoutTask.cancel();
timeoutTask = null;
Expand Down

0 comments on commit 7446beb

Please sign in to comment.