diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/LauncherUtil.java b/test-framework/common/src/main/java/io/quarkus/test/common/LauncherUtil.java index 7dd17e1412445..42ceb92438d8c 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/LauncherUtil.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/LauncherUtil.java @@ -70,7 +70,7 @@ 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) { @@ -78,6 +78,29 @@ static ListeningAddress waitForCapturedListeningData(Process quarkusProcess, Pat } } + /** + * 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