From 56f01f3b110f0832b0c0cd8b65a646eab0b74162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Vav=C5=99=C3=ADk?= Date: Wed, 25 Oct 2023 12:29:06 +0200 Subject: [PATCH] Fix calling of ServiceListeners on error --- .../quarkus/test/bootstrap/BaseService.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/quarkus-test-core/src/main/java/io/quarkus/test/bootstrap/BaseService.java b/quarkus-test-core/src/main/java/io/quarkus/test/bootstrap/BaseService.java index fa929b7e9..17a0bf489 100644 --- a/quarkus-test-core/src/main/java/io/quarkus/test/bootstrap/BaseService.java +++ b/quarkus-test-core/src/main/java/io/quarkus/test/bootstrap/BaseService.java @@ -283,9 +283,9 @@ private void doStart() { try { managedResource.start(); listeners.forEach(ext -> ext.onServiceStarted(context)); - } catch (Exception ex) { - listeners.forEach(ext -> ext.onServiceError(context, ex)); - throw ex; + } catch (Throwable t) { + listeners.forEach(ext -> ext.onServiceError(context, t)); + throw t; } } @@ -299,14 +299,19 @@ private boolean isRunningOrFailed() { } private void waitUntilServiceIsStarted() { - Duration startupCheckInterval = getConfiguration() - .getAsDuration(SERVICE_STARTUP_CHECK_POLL_INTERVAL, SERVICE_STARTUP_CHECK_POLL_INTERVAL_DEFAULT); - Duration startupTimeout = getConfiguration() - .getAsDuration(SERVICE_STARTUP_TIMEOUT, SERVICE_STARTUP_TIMEOUT_DEFAULT); - untilIsTrue(this::isRunningOrFailed, AwaitilitySettings - .using(startupCheckInterval, startupTimeout) - .doNotIgnoreExceptions() - .withService(this) - .timeoutMessage("Service didn't start in %s minutes", startupTimeout)); + try { + Duration startupCheckInterval = getConfiguration() + .getAsDuration(SERVICE_STARTUP_CHECK_POLL_INTERVAL, SERVICE_STARTUP_CHECK_POLL_INTERVAL_DEFAULT); + Duration startupTimeout = getConfiguration() + .getAsDuration(SERVICE_STARTUP_TIMEOUT, SERVICE_STARTUP_TIMEOUT_DEFAULT); + untilIsTrue(this::isRunningOrFailed, AwaitilitySettings + .using(startupCheckInterval, startupTimeout) + .doNotIgnoreExceptions() + .withService(this) + .timeoutMessage("Service didn't start in %s minutes", startupTimeout)); + } catch (Throwable t) { + listeners.forEach(ext -> ext.onServiceError(context, t)); + throw t; + } } }