Skip to content

Commit

Permalink
Give processes launched by @QuarkusIntegrationTest a chance to termin…
Browse files Browse the repository at this point in the history
…ate normally

This is especially useful when launching a docker container because
the '--rm' flag of 'docker run' takes only if the process is terminated
normally

Fixes: quarkusio#17737
  • Loading branch information
geoand committed Jun 8, 2021
1 parent 4320b9b commit de12100
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,37 @@ static ListeningAddress waitForCapturedListeningData(Process quarkusProcess, Pat
if (result != null) {
return result;
}
quarkusProcess.destroyForcibly();
destroyProcess(quarkusProcess);
throw new IllegalStateException(
"Unable to determine the status of the running process. See the above logs for details");
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted while waiting to capture listening process port and protocol");
}
}

/**
* Try to destroy the process normally a few times
* and resort to forceful destruction if necessary
*/
private static void destroyProcess(Process quarkusProcess) {
quarkusProcess.destroy();
int i = 0;
while (i++ < 10) {
try {
Thread.sleep(500);
} catch (InterruptedException ignored) {

}
if (!quarkusProcess.isAlive()) {
break;
}
}

if (quarkusProcess.isAlive()) {
quarkusProcess.destroyForcibly();
}
}

/**
* Updates the configuration necessary to make all test systems knowledgeable about the port on which the launched
* process is listening
Expand Down

0 comments on commit de12100

Please sign in to comment.