You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/08/07 17:26:09 UTC

[camel] branch main updated: CAMEL-19720: fix not printing failure details when failing to initialize service

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 59617482f7a CAMEL-19720: fix not printing failure details when failing to initialize service
59617482f7a is described below

commit 59617482f7a6bd0813df109ea67dbc996c27ca29
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Aug 7 18:28:30 2023 +0200

    CAMEL-19720: fix not printing failure details when failing to initialize service
---
 .../camel/test/infra/common/services/TestServiceUtil.java   | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/TestServiceUtil.java b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/TestServiceUtil.java
index 95e8d32ff95..8ab8fb781a0 100644
--- a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/TestServiceUtil.java
+++ b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/TestServiceUtil.java
@@ -70,10 +70,17 @@ public final class TestServiceUtil {
      */
     public static void logAndRethrow(TestService service, ExtensionContext extensionContext, Exception exception)
             throws Exception {
-        final Object o = extensionContext.getTestInstance().get();
+        final Object testInstance = extensionContext.getTestInstance().orElse(null);
+
+        if (testInstance != null) {
+            LOG.error("Failed to initialize service {} for test {} on ({})", service.getClass().getSimpleName(),
+                    extensionContext.getDisplayName(), testInstance.getClass().getName());
+        } else {
+            LOG.error("Failed to initialize service {} for test {}", service.getClass().getSimpleName(),
+                    extensionContext.getDisplayName());
+        }
+
 
-        LOG.error("Failed to initialize service {} for test {} on ({})", service.getClass().getSimpleName(),
-                extensionContext.getDisplayName(), o.getClass().getName());
         throw exception;
     }
 }